Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Lemma 4 — discrete costs give finitely many possible steps

Proved
MasekPaterson.FourRussians.possibleSteps_finite

by mikedeng1 · Sep 26, 2026 · Mathlib 0df444a (Lean v4.33.1)

dynamic-programmingedit-distancep2o-batch-p100ap2o-gran-per-chapterp2o-plan-paperp2o-v1

Let Σ\SigmaΣ be a finite alphabet and γ\gammaγ a nonnegative cost function whose cost set Ω={Da}∪{Ia}∪{Ra,b}\Omega = \{D_a\} \cup \{I_a\} \cup \{R_{a,b}\}Ω={Da​}∪{Ia​}∪{Ra,b​} is discrete, i.e. there is r>0r > 0r>0 such that every element of Ω\OmegaΩ is an integral multiple of rrr. Then the set of possible steps

{δi,j−δi−1,j}∪{δi,j−δi,j−1},\{\delta_{i,j} - \delta_{i-1,j}\} \cup \{\delta_{i,j} - \delta_{i,j-1}\},{δi,j​−δi−1,j​}∪{δi,j​−δi,j−1​},

taken over all strings A,B∈Σ∗A, B \in \Sigma^*A,B∈Σ∗ and all adjacent pairs of entries of their edit matrices, is finite.

This is what makes the precomputation of Algorithm Y finite: its table ranges over pairs of length-mmm strings and pairs of length-mmm vectors of possible steps, a set whose size does not depend on the strings being compared.

Formalization Note Normalization of γ\gammaγ is not assumed. Steps on the boundary row and column of the matrix are included in the set.

Preamble
import Mathlib
import Definitions.Def_MasekPaterson_Shared_editDist
import Definitions.Def_MasekPaterson_Shared_steps
open MasekPaterson.Shared
Formal statement
namespace MasekPaterson.FourRussians

/-- Lemma 4: over a finite alphabet, if the set `Ω` of edit costs is discrete then the set
of possible steps in edit matrices is finite. -/
theorem possibleSteps_finite {α : Type*} [Fintype α] (γ : EditOp α → ℝ) (hγ : ∀ o, 0 ≤ γ o)
    (hΩ : IsDiscrete γ) :
    (possibleSteps γ).Finite := by sorry

end MasekPaterson.FourRussians
Source
Masek, Paterson, A Faster Algorithm Computing String Edit Distances, J. Comput. System Sci. 20, 1980, p. 23, Lemma 4
Read-back

What the Lean code literally says, in plain math · claude-opus-5-5

Let α\alphaα be a finite type and γ\gammaγ a real-valued cost function on edit operations over α\alphaα (a type defined in the imported shared file). There are two assumptions:

  • γ(o)≥0\gamma(o)\ge0γ(o)≥0 for every edit operation ooo;
  • γ\gammaγ satisfies the imported predicate IsDiscrete, whose definition is not reproduced here.

No normalisation hypothesis is present. The conclusion is that the set possibleSteps(γ)⊆R\mathrm{possibleSteps}(\gamma)\subseteq\mathbb RpossibleSteps(γ)⊆R is finite. This set is imported from the shared steps file and its definition is not shown; the docstring describes it as the set of possible steps in edit matrices. What exactly is being bounded, and what IsDiscrete requires, therefore depends entirely on the imported definitions.

In the degenerate cases:

  • α\alphaα empty. The only strings are empty, and the claim reduces to whatever possibleSteps(γ)\mathrm{possibleSteps}(\gamma)possibleSteps(γ) means over an empty alphabet.
  • IsDiscrete unsatisfiable. If it could not be satisfied together with nonnegativity, the statement would be vacuous. This cannot be judged from the code shown.
Human review
  • Endorsed by Shuze Chen · Sep 27, 2026

    Confirmed by the moderator at approval.

  • Endorsed by mikedeng1 · Sep 27, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me