Zulip Chat Archive

Stream: general

Topic: request for lemmas about Array and List .isPrefixOf


Frederick Pu (Feb 21 2026 at 22:50):

I think the following characterizing lemmas of isPrefixOf are very useful when trying to prove stuff about programs that use the function

theorem Array.isPrefixOf_toList_isPrefixOf {α} [BEq α] (x y : Array α) : x.isPrefixOf y  x.toList.isPrefixOf y.toList := sorry

theorem List.subset_of_isPrefixOf {α} [BEq α] (x y : List α) : x.isPrefixOf y  x  y := sorry

Frederick Pu (Feb 21 2026 at 22:50):

would it be possible to get a PR for proving these?

Frederick Pu (Feb 21 2026 at 22:50):

also should this go into batteries or mathlib

Ruben Van de Velde (Feb 21 2026 at 22:51):

Are you asking someone else to prove these lemmas for you, or are you saying that you proved them?

Frederick Pu (Feb 21 2026 at 22:51):

i haven't proved them yet

Frederick Pu (Feb 21 2026 at 22:51):

and i cant find them in mathlib anywhere

Frederick Pu (Feb 21 2026 at 22:52):

i think i should be able to prove both myself since it's just induction

Ruben Van de Velde (Feb 21 2026 at 22:52):

That's probably a good place to start, then

Ruben Van de Velde (Feb 21 2026 at 22:53):

Though loogle found docs#Array.isPrefixOf_toList

Frederick Pu (Feb 21 2026 at 22:54):

any luck on the sublist?

Ruben Van de Velde (Feb 21 2026 at 22:55):

Assuming LawfulBEq, you get docs#List.isPrefixOf_iff_prefix and docs#List.IsPrefix.subset

Frederick Pu (Feb 21 2026 at 22:59):

it's weird that grind doesn't always use this lemma tho:
docs#Array.isPrefixOf_toList

Frederick Pu (Feb 21 2026 at 23:01):

nvm i accidently expanded Array.isPrefixOf before using the grind


Last updated: Feb 28 2026 at 14:05 UTC