The block algorithm (Algorithms Y and Z) computes from a string-independent finite table
ProvedMasekPaterson.FourRussians.algZ_correct_finite_tableLet be a finite alphabet and a nonnegative, normalized cost function whose cost set is discrete. Then there is a finite set such that for every block size and all strings with and :
- Algorithm Z, with given by Algorithm Y, returns
- every entry of every step vector (, ) and (, ) computed by Algorithm Z lies in .
The set is chosen before , and . Consequently every call made by Algorithm Z is answered from the table of Algorithm Y over , a table whose size depends only on , and and not on the strings. These are the two facts on which the paper's running time rests.
Formalization Note The paper states a running time on a logarithmic-cost RAM; this statement formalizes the two facts the bound rests on, correctness and a string-independent finite table domain. The RAM cost model, the operation counts and the choice are not formalized, nor is the padding reduction for . The standing assumption is dropped. Algorithms Y and Z are transcribed from the pseudo-code and do not refer to .
import Mathlib import Definitions.Def_MasekPaterson_Shared_editDist import Definitions.Def_MasekPaterson_Shared_steps import Definitions.Def_MasekPaterson_FourRussians_algorithms open MasekPaterson.Shared
namespace MasekPaterson.FourRussians
/-- Correctness of the Masek–Paterson block algorithm with a string-independent finite table
(§2.2, Algorithm Z with Fetch = Algorithm Y). Over a finite alphabet, for a nonnegative
normalized cost function whose cost set `Ω` is discrete, there is one finite set `T` of
reals such that for every block size `m ≥ 1` and all strings `A, B` with `m ∣ |A|` and
`m ∣ |B|`: Algorithm Z returns `δ(γ, A, B)`, and every entry of every step vector
`P(i, j)` (`1 ≤ i ≤ |A|/m`, `0 ≤ j ≤ |B|/m`) and `Q(i, j)` (`0 ≤ i ≤ |A|/m`,
`1 ≤ j ≤ |B|/m`) that Algorithm Z computes lies in `T`. -/
theorem algZ_correct_finite_table {α : Type*} [Fintype α] (γ : EditOp α → ℝ)
(hγ : ∀ o, 0 ≤ γ o) (hN : IsNormalized γ) (hΩ : IsDiscrete γ) :
∃ T : Finset ℝ, ∀ m : ℕ, 0 < m → ∀ A B : List α, m ∣ A.length → m ∣ B.length →
algZ γ m A B = editDist γ A B ∧
(∀ i j : ℕ, 1 ≤ i → i ≤ A.length / m → j ≤ B.length / m →
∀ k : Fin m, algZ_P γ m A B i j k ∈ T) ∧
(∀ i j : ℕ, i ≤ A.length / m → 1 ≤ j → j ≤ B.length / m →
∀ k : Fin m, algZ_Q γ m A B i j k ∈ T) := by sorry
end MasekPaterson.FourRussians
Read-back
What the Lean code literally says, in plain math · claude-opus-5-5
Let be any type with finitely many elements (an alphabet, possibly empty or with a single letter). Let be a real-valued function on , a type defined in the imported bundle whose construction is not shown here. Presumably it describes edit operations over , and assigns each one a real cost. The statement assumes three things about :
- for every ;
- satisfies the bundle predicate ;
- satisfies the bundle predicate .
The definitions of and are not included in the code provided. Their exact content, and whether they can be satisfied together with nonnegativity, cannot be read off from this declaration. If no satisfies all three, the statement holds vacuously.
The statement uses the following objects from the imported bundle, none of whose definitions are shown:
- (
editDist) is a value computed from and two finite lists of letters from . - (
algZ) is a value computed from , a natural number , and . - and (
algZ_P,algZ_Q) are defined for all natural numbers . Each is a vector of real entries, indexed by .
Conclusion. Under these hypotheses there exists a single finite set with the following property. depends only on and ; it is chosen before, and independently of, , and . For every natural number and all lists over whose lengths and are both divisible by , three things hold.
- The two values are exactly equal:
- For all natural numbers with and , and every :
- For all natural numbers with and , and every :
The divisions and are natural-number (floor) divisions. Because divisibility is assumed, they are exact quotients here. The statement says nothing about or at index pairs outside these ranges. It also says nothing about how large is, how is built, or whether it is minimal: it only claims that some finite exists. The substance of the membership claims is that one finite works for every block size and every pair of lists at once. For any single fixed input, only finitely many entries are involved, so a finite set containing them exists trivially.
Degenerate cases. The value is excluded, and is allowed. In that case every length is divisible by , and the vectors have one entry each.
- empty. Length is divisible by every . The clause is vacuous, because no satisfies . The clause concerns only and .
- empty. Symmetrically, the clause is vacuous, and the clause concerns only .
- Both and empty. Both membership clauses are vacuous. The statement then asserts only for every .
- empty. The only list is the empty one, so the whole statement reduces to that last equality, with allowed to be any finite set, including . What , and hence and the three hypotheses, amount to in this case depends on definitions not shown.
- Single-letter . No special treatment: the statement applies to all lists over that letter.
- Default values. Apart from the floor divisions, which are exact here, the statement itself contains no division, natural-number subtraction, integral or supremum that could produce a default value. Whether
editDist,algZ,algZ_PoralgZ_Qrely internally on such default values cannot be determined from the code provided.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.