Algorithm Y returns the final step vectors of every submatrix
ProvedMasekPaterson.FourRussians.blockY_final_stepsLet be a nonnegative, normalized cost function and strings with edit matrix . Consider the submatrix, whose upper-left entry is , with and . Run Algorithm Y on the strings and and the submatrix's actual initial step vectors
Then its output is the submatrix's actual pair of final step vectors:
This is the statement, made in Section 2.1, that each submatrix is determined by its two initial step vectors and its two strings, and that Algorithm Y computes its final step vectors; Algorithm Z relies on it for every block.
Formalization Note The paper states this in prose ("each submatrix may be determined by a starting value , two initial step vectors … along with the two strings", and "Algorithm Y calculates a submatrix of steps according to Corollary 1"); it is not a numbered result. Vectors are 0-based in Lean: entry k : Fin m is the paper's entry . For the statement is trivially true.
import Mathlib import Definitions.Def_MasekPaterson_Shared_editDist import Definitions.Def_MasekPaterson_FourRussians_algorithms open MasekPaterson.Shared
namespace MasekPaterson.FourRussians
/-- Algorithm Y computes a submatrix's final step vectors (§2.1): for the `(i, j, m)`
submatrix of the edit matrix of `A, B` (upper-left entry `δ_{i,j}`, with `i + m ≤ |A|`,
`j + m ≤ |B|`), Algorithm Y applied to the strings `C = A^{i+1,i+m}`, `D = B^{j+1,j+m}` and
the actual initial step vectors `R = ⟨δ_{i+k,j} − δ_{i+k−1,j}⟩_{k=1..m}` (left column) and
`S = ⟨δ_{i,j+k} − δ_{i,j+k−1}⟩_{k=1..m}` (top row) returns the actual final step vectors
`R' = ⟨δ_{i+k,j+m} − δ_{i+k−1,j+m}⟩_{k=1..m}` (right column) and
`S' = ⟨δ_{i+m,j+k} − δ_{i+m,j+k−1}⟩_{k=1..m}` (bottom row). Vectors are 0-based in Lean:
entry `k : Fin m` is the paper's entry `k + 1`. -/
theorem blockY_final_steps {α : Type*} (γ : EditOp α → ℝ) (hγ : ∀ o, 0 ≤ γ o)
(hN : IsNormalized γ) (A B : List α) (i j m : ℕ)
(hiA : i + m ≤ A.length) (hjB : j + m ≤ B.length) :
blockY γ m
(fun k => A[i + k.val]) (fun k => B[j + k.val])
(fun k => dmat γ A B (i + k.val + 1) j - dmat γ A B (i + k.val) j)
(fun k => dmat γ A B i (j + k.val + 1) - dmat γ A B i (j + k.val)) =
(fun k => dmat γ A B (i + k.val + 1) (j + m) - dmat γ A B (i + k.val) (j + m),
fun k => dmat γ A B (i + m) (j + k.val + 1) - dmat γ A B (i + m) (j + k.val)) := 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). There are two assumptions:
- for all ;
- satisfies the imported, unshown predicate
IsNormalized.
Let be finite lists over with 1-based entries. Write for the imported dmat γ A B r s, which the docstring calls the edit matrix. Let with and . Both and are allowed.
Form the following length- inputs, indexed :
- the strings and ;
- the real vectors
is the imported block routine. It fills a table as follows:
- boundary values and ;
- for :
It returns the pair of vectors . Here , and are the imported replacement, deletion and insertion costs under .
The theorem asserts the equality of pairs of vectors
In the degenerate cases:
- When , both sides are pairs of empty vectors and the claim is trivially true for all and .
- When or , the block touches the boundary row or column of , and the input steps are differences of those boundary entries.
- If
IsNormalizedwere incompatible with nonnegativity, the statement would be vacuous. This cannot be judged from the code shown.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.