§2.3 — for a normalized cost function, δ_{i,j} is the minimum cost of an edit path from (0, 0) to (i, j)
ProvedMasekPaterson.Necessity.editDist_eq_pathMinLet be a cost function assigning a nonnegative real number to every edit operation, normalized as in §1.1: for every edit operation . Let and be strings over the alphabet, with prefixes , and edit matrix . An edit path from to is a sequence of moves through the matrix, each increasing , , or both by : the move deletes at cost , the move inserts at cost , and the move replaces by at cost . Then for all ,
In words: to transform into it is enough to consider edit sequences that proceed left to right through the two strings, which are exactly the edit paths through the matrix. This identifies the edit distance, defined as a minimum over arbitrary edit sequences, with the path costs that §4 compares.
Formalization Note The strings are given as 1-based infinite sequences whose prefixes are , (every finite string over a nonempty alphabet is such a prefix). The nonnegativity of and the normalization are the standing assumptions of §1.1 (p. 19), stated as hypotheses. The paper's assumption is not used.
import Mathlib import Definitions.Def_MasekPaterson_Shared_editDist import Definitions.Def_MasekPaterson_Necessity_editPaths open MasekPaterson.Shared
namespace MasekPaterson.Necessity
/-- §2.3: for a nonnegative normalized cost function `γ` (`γ(a → b) = δ(γ, a, b)`, §1.1) and
any strings `A, B` (given as 1-based sequences, `A^i = A_1 ⋯ A_i`), every edit matrix entry
`δ_{i,j} = δ(γ, A^i, B^j)` is the minimum cost of an edit path from `(0, 0)` to `(i, j)`. -/
theorem editDist_eq_pathMin {α : Type*} (γ : EditOp α → ℝ) (hγ : ∀ o, 0 ≤ γ o)
(hnorm : IsNormalized γ) (A B : ℕ → α) (i j : ℕ) :
editDist γ (List.ofFn fun t : Fin i => A (t.val + 1))
(List.ofFn fun t : Fin j => B (t.val + 1)) =
pathMin γ A B (0, 0) (i, j) := by sorry
end MasekPaterson.Necessity
Read-back
What the Lean code literally says, in plain math · claude-opus-5-5
Setting. Let be an arbitrary type, the alphabet, in any universe. It has no finiteness, decidability or ordering assumptions.
- is a type of edit operations over , defined in an imported file. Its definition is not shown here.
- is a real-valued cost function on edit operations.
- are infinite sequences of letters.
- are natural numbers.
Hypotheses.
- Nonnegativity: every edit operation has nonnegative cost:
- Normalization: satisfies a predicate called . It is defined in an imported file whose body is not shown here, so this read-back cannot say what it requires. The attached doc comment describes the intent as , but the code as shown does not confirm this.
Conclusion. Form the finite words
which are the entries of at positions through and of at positions through . The entries and are never used. The statement asserts
- is a real-valued function of and two finite lists, imported from a shared definitions file.
- is a real-valued quantity imported from an "edit paths" definitions file. It depends on , on the whole sequences and (not just their first and entries), on the start point and on the end point in .
Neither definition is shown here, so this read-back cannot spell out either side. The names and the doc comment say that the left side is the edit distance between the prefixes and the right side is the minimum cost of an edit path from to . Whether the code actually means this depends entirely on the two imported definitions. In particular, whether can look at , or at entries beyond positions and cannot be seen from this code.
The equation is claimed for every , every meeting both hypotheses, every and , and every pair .
Degenerate cases.
- or : the corresponding word is empty. The claim is then that the edit distance involving an empty word equals from to , or . For , the edit distance between two empty words equals from to itself.
- Empty alphabet: if is empty, no sequences exist, so the statement holds vacuously.
- One-letter alphabet: if has one element, both words are constant and only their lengths and differ.
- Arbitrary costs: may assign cost to every operation, as far as the nonnegativity hypothesis goes. Whether that passes is not visible.
- Can the hypotheses be met? That depends on the hidden definitions of and . If no nonnegative can satisfy , the theorem is vacuous; this read-back cannot rule that out.
- Junk values: no division, natural-number subtraction, integral or supremum appears in the statement itself. Any such default values inside or , such as a minimum or infimum over an empty set of paths, are not visible here.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.