string_overlap_merge
For two lists x, y : List Γ over an alphabet type Γ with decidable equality, the overlap merge ⟨x,y⟩ is the list consisting of the first x.length − string_overlap_len x y entries of x followed by all of y.
Statement
def string_overlap_merge {Γ : Type*} [DecidableEq Γ] (x y : List Γ) : List Γ
- Defined in
- arXiv:2611.16573, Section 2
- Verified
- 14 Nov 2026
- Axioms
- none listed
- Built on 1
- string_overlap_lenFor two lists x, y : List Γ over an arbitrary alphabet type Γ with decidable equality (strings are lists of letters, not Lean Strings),…
- Used by 5
- 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 ''…
- 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_merge_sanity⟨123, 234⟩ = 1234.
Read back from the Lean
For any type Γ with decidable equality, and any two lists x, y : List Γ, string_overlap_merge x y is the list obtained by taking the prefix of x of length x.length - string_overlap_len x y and concatenating it with y, where string_overlap_len x y is the largest natural number k ≤ min x.length y.length such that k < x.length, k < y.length, and the suffix of x of length k (x.drop (x.length - k)) equals the prefix of y of length k (y.take k) (or 0 if no such k exists).
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
/-- The overlap merge ⟨x, y⟩ = pref(x, y) y. -/ def string_overlap_merge {Γ : Type*} [DecidableEq Γ] (x y : List Γ) : List Γ := x.take (x.length - string_overlap_len x y) ++ y