Infixes of a three-part concatenation, and prefixes #
An infix of u ++ m ++ v lies within u ++ m, lies within m ++ v, or contains m. So an infix
no longer than m cannot contain both an element that occurs only in u and an element that
occurs only in v: this is the fact about short windows that pumping arguments use, when m is a
block of the pumped word that separates two others.
The longest common prefix List.commonPrefix l₁ l₂ is the greatest list that is a prefix of
both, the meet of the prefix order.
Main definitions #
List.commonPrefix: the longest common prefix of two lists.
Main results #
List.IsInfix.infix_append_or_infix_append_or_infix: an infix ofu ++ m ++ vis an infix ofu ++ mor ofm ++ v, or containsm.List.IsInfix.notMem_or_notMem_of_length_le: an infix ofu ++ m ++ vno longer thanmmisses every element occurring only inuor every element occurring only inv.List.pairwise_inits: the prefixesinitslists ascend in the prefix order.List.takeWhile_bne_prefix_of_mem: what precedes the firstcis a prefix of what precedes the firstd, whenccomes before the firstd.
Implementation notes #
[UPSTREAM] candidate: Mathlib/Data/List/Infix.lean, or core Init/Data/List/Sublist.lean beside
List.infix_append_iff. Neither core, Batteries nor mathlib defines a longest common prefix of
lists.
An infix of u ++ m ++ v is an infix of u ++ m, an infix of m ++ v, or contains m.
An infix of u ++ m ++ v no longer than m misses an element that occurs only in u or an
element that occurs only in v.
commonPrefix l₁ l₂ is the longest common prefix of l₁ and l₂.
Equations
- (a :: as).commonPrefix (b :: bs) = if a = b then a :: as.commonPrefix bs else []
- x✝¹.commonPrefix x✝ = []
Instances For
An element before the first d cuts off a prefix of what comes before the first d.
The prefixes of a list, as inits lists them, ascend in the prefix order.