mgreedy_rc_step
For cm : Γ → Γ and states st = (S, T), st' : Finset (List Γ) × Finset (List Γ), mgreedy_rc_step cm st st' holds when, with V = S ∪ rev_comp cm '' S, there are x, y ∈ V that are allowed (x = y, or y ≠ x and y ≠ rev_comp cm x), whose string_overlap_len x y is at least string_overlap_len x' y' for every allowed pair x', y' ∈ V, and either x = y and st' = (S \ {x, rev_comp cm x}, insert x T), or x ≠ y and st' = (insert (string_overlap_merge x y) (S \ {x, rev_comp cm x, y, rev_comp cm y}), T). This is one iteration of MGREEDY-RC with arbitrary tie-breaking.
Statement
def mgreedy_rc_step {Γ : Type*} [DecidableEq Γ] (cm : Γ → Γ) (st st' : Finset (List Γ) × Finset (List Γ)) : Prop
- Defined in
- arXiv:2611.16573, Algorithm 1
- Verified
- 14 Nov 2026
- Axioms
- none listed
- Built on 3
- rev_compThe reverse complement rc(s) of a string s = a_1…a_m under a complement map cm is cm(a_m)…cm(a_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),…
- 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…
- Used by 3
- tgreedy_rc_output_sanityWith cm = id, TGREEDY-RC on {12} can output 12.
- tgreedy_rc_two_point_five_approx_of_partsIf t is an output of TGREEDY-RC on S, every MGREEDY-RC output T from S is RC-substring-free, GREEDY-RC from any RC-substring-free T to {t}…
- tgreedy_rc_outputFor cm : Γ → Γ, S : Finset (List Γ) and t : List Γ, tgreedy_rc_output cm S t holds when there is T : Finset (List Γ) such that the state…
Read back from the Lean
Given a type Γ with decidable equality, a character complement map cm : Γ → Γ, and two states st, st' : Finset (List Γ) × Finset (List Γ), mgreedy_rc_step cm st st' asserts that there exist lists x and y such that:
1. Both x and y belong to st.1 ∪ st.1.image (rev_comp cm) (the set of contigs in st.1 along with their reverse complements under cm).
2. Either x = y, or y ≠ x and y ≠ rev_comp cm x (i.e., y is not the reverse complement of x, unless x = y).
3. For all x' and y' in st.1 ∪ st.1.image (rev_comp cm), if x' = y' ∨ (y' ≠ x' ∧ y' ≠ rev_comp cm x'), then string_overlap_len x' y' ≤ string_overlap_len x y (the pair (x, y) maximizes the overlap length among all valid pairs).
4. And the next state st' is given by:
- If x = y: st' = (st.1 \ {x, rev_comp cm x}, insert x st.2) (both x and its reverse complement are removed from st.1, and x is inserted into st.2);
- If x ≠ y: st' = (insert (string_overlap_merge x y) (st.1 \ {x, rev_comp cm x, y, rev_comp cm y}), st.2) (both x, y, and their reverse complements are removed from st.1, their merged string is inserted into st.1, and st.2 is unchanged).
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
/-- One iteration of the while loop of MGREEDY-RC (Algorithm 1) on the state (S, T), with any tie-breaking among the pairs of maximum overlap. -/ def mgreedy_rc_step {Γ : Type*} [DecidableEq Γ] (cm : Γ → Γ) (st st' : Finset (List Γ) × Finset (List Γ)) : Prop := ∃ x ∈ st.1 ∪ st.1.image (rev_comp cm), ∃ y ∈ st.1 ∪ st.1.image (rev_comp cm), (x = y ∨ (y ≠ x ∧ y ≠ rev_comp cm x)) ∧ (∀ x' ∈ st.1 ∪ st.1.image (rev_comp cm), ∀ y' ∈ st.1 ∪ st.1.image (rev_comp cm), (x' = y' ∨ (y' ≠ x' ∧ y' ≠ rev_comp cm x')) → string_overlap_len x' y' ≤ string_overlap_len x y) ∧ ((x = y ∧ st' = (st.1 \ {x, rev_comp cm x}, insert x st.2)) ∨ (x ≠ y ∧ st' = (insert (string_overlap_merge x y) (st.1 \ {x, rev_comp cm x, y, rev_comp cm y}), st.2)))