Lemma 3 — steps of an edit matrix lie in and
ProvedMasekPaterson.FourRussians.step_boundsLet be a nonnegative cost function, and let be real numbers with and for every character (for a finite alphabet, the paper's and ). Then for all strings and all with , ,
- , and
- .
The size of a step is therefore bounded independently of the strings involved, which is the first half of the finiteness of the set of steps (Lemma 4).
Formalization Note The paper's and are maxima over a finite alphabet; the statement is given for arbitrary upper bounds , which implies the paper's version (take the maxima) and needs neither finiteness nor nonemptiness of the alphabet. Normalization of is not assumed: the lemma holds for every nonnegative cost function.
import Mathlib import Definitions.Def_MasekPaterson_Shared_editDist open MasekPaterson.Shared
namespace MasekPaterson.FourRussians
/-- Lemma 3: if every insertion cost is at most `I` and every deletion cost at most `D`
(in particular for `I = max_a I_a`, `D = max_a D_a` over a finite alphabet), then for all
strings `A, B` and `1 ≤ i ≤ |A|`, `1 ≤ j ≤ |B|`:
(i) `−I ≤ δ_{i,j} − δ_{i−1,j} ≤ D`, and (ii) `−D ≤ δ_{i,j} − δ_{i,j−1} ≤ I`. -/
theorem step_bounds {α : Type*} (γ : EditOp α → ℝ) (hγ : ∀ o, 0 ≤ γ o)
(I D : ℝ) (hI : ∀ a : α, insCost γ a ≤ I) (hD : ∀ a : α, delCost γ a ≤ D)
(A B : List α) (i j : ℕ)
(hi : 1 ≤ i) (hiA : i ≤ A.length) (hj : 1 ≤ j) (hjB : j ≤ B.length) :
(-I ≤ dmat γ A B i j - dmat γ A B (i - 1) j ∧ dmat γ A B i j - dmat γ A B (i - 1) j ≤ D) ∧
(-D ≤ dmat γ A B i j - dmat γ A B i (j - 1) ∧ dmat γ A B i j - dmat γ A B i (j - 1) ≤ I) := by sorry
end MasekPaterson.FourRussians
Read-back
What the Lean code literally says, in plain math · claude-opus-5-5
Let be any type and a real-valued cost function on edit operations over (a type defined in the imported shared file). Assume for all . No normalisation hypothesis appears in this statement, and is not assumed finite.
Let be real numbers such that, for every symbol :
- ;
- .
Here and are the imported insertion and deletion costs under . Let be finite lists over , and write for the imported dmat γ A B r s (the edit matrix per the docstring; its definition is not shown).
For all natural numbers with and , the statement asserts both chains of inequalities:
In the degenerate cases:
- If or is empty, the statement is vacuous.
- If is empty, every list is empty, so the statement is again vacuous, and the bound hypotheses hold for every choice of .
- If is nonempty but the insertion or deletion costs are unbounded above, no real or satisfies the hypotheses, so the statement is vacuous for such .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.