Theorem 1 [7] — the first row and column of the edit matrix
ProvedMasekPaterson.FourRussians.initial_vectorsLet be a nonnegative, normalized cost function (that is, for every edit operation), and let be strings with edit matrix . Then , and
This gives the initial vectors (first row and column) of the edit matrix, from which the Wagner–Fischer recurrence (Theorem 2) computes the rest. The paper cites it from Wagner and Fischer [7].
Formalization Note The paper states both formulas under the joint condition ""; each formula involves only one of the two indices, so each is stated with its own range, which is the same content and does not become vacuous when the other string is empty. The paper's standing assumption (used only for running times) is dropped. is written as the sum of over the first characters of .
import Mathlib import Definitions.Def_MasekPaterson_Shared_editDist open MasekPaterson.Shared
namespace MasekPaterson.FourRussians
/-- Theorem 1 [Wagner–Fischer]: `δ_{0,0} = 0`, `δ_{i,0} = ∑_{1≤r≤i} D_{A_r}` for
`1 ≤ i ≤ |A|`, and `δ_{0,j} = ∑_{1≤r≤j} I_{B_r}` for `1 ≤ j ≤ |B|`, for a nonnegative
normalized cost function. -/
theorem initial_vectors {α : Type*} (γ : EditOp α → ℝ) (hγ : ∀ o, 0 ≤ γ o)
(hN : IsNormalized γ) (A B : List α) :
dmat γ A B 0 0 = 0 ∧
(∀ i : ℕ, 1 ≤ i → i ≤ A.length → dmat γ A B i 0 = ((A.take i).map (delCost γ)).sum) ∧
(∀ j : ℕ, 1 ≤ j → j ≤ B.length → dmat γ A B 0 j = ((B.take j).map (insCost γ)).sum) := 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 . The type of edit operations is defined in the imported shared file. There are two assumptions:
- for every edit operation ;
- satisfies the predicate
IsNormalized. This predicate is imported and not shown, so its content (and whether it is compatible with nonnegativity) cannot be read off this code.
Let and be finite lists over . Write for dmat γ A B i j. This is an imported function of whose definition is not reproduced here; the docstring calls it the edit matrix. Likewise and are the imported deletion and insertion costs under . The statement asserts three facts together:
In the degenerate cases:
- If is empty, the second claim is vacuous; if is empty, the third is vacuous. For two empty lists only is asserted.
- If is empty, every list is empty and only remains.
- Nothing is asserted about for or for .
- If
IsNormalizedtogether with nonnegativity were unsatisfiable, the whole statement would be vacuous. That cannot be decided from the code shown.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.