string_overlap_len
For two lists x, y : List Γ over an arbitrary alphabet type Γ with decidable equality (strings are lists of letters, not Lean Strings), string_overlap_len x y is the largest natural number k with k < x.length and k < y.length (both strict, so the overlap is proper) such that the last k entries of x equal the first k entries of y, and 0 if no such k exists.
Statement
def string_overlap_len {Γ : Type*} [DecidableEq Γ] (x y : List Γ) : ℕ
- Defined in
- arXiv:2611.16573, Section 2
- Verified
- 14 Nov 2026
- Axioms
- none listed
- Used by 6
- tgreedy_rc_output_sanityWith cm = id, TGREEDY-RC on {12} can output 12.
- greedy_rc_step_sanityWith cm = id, one GREEDY-RC step on {12, 23} gives {123}.
- greedy_rc_stepFor cm : Γ → Γ and S, S' : Finset (List Γ), greedy_rc_step cm S S' holds when S has more than one element and, with V = S ∪ rev_comp cm ''…
- string_overlap_mergeFor two lists x, y : List Γ over an alphabet type Γ with decidable equality, the overlap merge ⟨x,y⟩ is the list consisting of the first…
- mgreedy_rc_stepFor cm : Γ → Γ and states st = (S, T), st' : Finset (List Γ) × Finset (List Γ), mgreedy_rc_step cm st st' holds when, with V = S ∪…
- string_overlap_len_sanityov(123,234) = 23, ov(11,11) = 1, ov(12,12) is empty.
Read back from the Lean
For a type Γ with decidable equality and two lists x, y : List Γ, string_overlap_len x y is defined as the greatest natural number k ≤ min x.length y.length such that:
1. k < x.length,
2. k < y.length, and
3. x.drop (x.length - k) = y.take k (the suffix of x of length k equals the prefix of y of length k),
defaulting to 0 if no such k exists (e.g. when x or y is empty).
Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.
Lean source view module on GitHub
/-- Length of the overlap ov(x, y): the longest v with x = u v and y = v w for nonempty u, w. -/ def string_overlap_len {Γ : Type*} [DecidableEq Γ] (x y : List Γ) : ℕ := Nat.findGreatest (fun k => k < x.length ∧ k < y.length ∧ x.drop (x.length - k) = y.take k) (min x.length y.length)