Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Theorem 5 — with costs 1 and π the steps δ_{k,k+1} − δ_{k,k} are pairwise distinct, so the set of possible steps is infinite

Proved
MasekPaterson.Necessity.steps_unbounded

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

edit-distancep2o-batch-p100ap2o-gran-per-chapterp2o-plan-paperp2o-v1strings

Let γ\gammaγ be the cost function and A,BA, BA,B the infinite strings of the §4.1 example over Σ={a,b,c}\Sigma = \{a, b, c\}Σ={a,b,c} (replacement costs 000, 111 and π\piπ, insertions and deletions 555), and δi,j=δ(γ,Ai,Bj)\delta_{i,j} = \delta(\gamma, A^i, B^j)δi,j​=δ(γ,Ai,Bj). Then:

  1. the horizontal steps δk,k+1−δk,k\delta_{k,k+1} - \delta_{k,k}δk,k+1​−δk,k​, for k=0,1,2,…k = 0, 1, 2, \dotsk=0,1,2,…, are pairwise distinct:
δk,k+1−δk,k=δk′,k′+1−δk′,k′  ⟹  k=k′;\delta_{k,k+1} - \delta_{k,k} = \delta_{k',k'+1} - \delta_{k',k'} \implies k = k';δk,k+1​−δk,k​=δk′,k′+1​−δk′,k′​⟹k=k′;
  1. the set of possible steps of γ\gammaγ (all differences of adjacent entries of the edit matrices of all pairs of strings over Σ\SigmaΣ) is infinite.

Part 1 shows that the edit matrix of AnA^nAn and BnB^nBn already contains at least nnn different steps, so the number of distinct steps grows linearly with the string length. Part 2 is the direct contrast with the paper's Lemma 4, which shows that the set of possible steps is finite whenever the alphabet is finite and the cost set is discrete; the example meets every other condition of the paper, so discreteness cannot be dropped.

Formalization Note The paper states Theorem 5 about the running time of Algorithm Y ("Discreteness is a necessary condition for Algorithm Y to run in time O(km)O(k^m)O(km) on length mmm strings and step sequences"); its proof establishes that the number of distinct steps grows linearly with the string length, which is what is stated here. Running time is not formalized.

Preamble
import Mathlib
import Definitions.Def_MasekPaterson_Shared_editDist
import Definitions.Def_MasekPaterson_Necessity_editPaths
import Definitions.Def_MasekPaterson_Necessity_example
import Definitions.Def_MasekPaterson_Shared_steps
open MasekPaterson.Shared
Formal statement
namespace MasekPaterson.Necessity

/-- Theorem 5, pinned to what its proof establishes: in the example, the horizontal steps
`δ_{k,k+1} - δ_{k,k}` (`k = 0, 1, 2, …`) are pairwise distinct, so the edit matrix of
`A^n, B^n` has at least `n` distinct steps, and the set of possible steps of the cost
function is infinite. -/
theorem steps_unbounded :
    Function.Injective (fun k : ℕ => exDelta k (k + 1) - exDelta k k) ∧
    ¬ (possibleSteps exCost).Finite := by sorry

end MasekPaterson.Necessity
Source
Masek, Paterson, A Faster Algorithm Computing String Edit Distances, J. Comput. System Sci. 20, 1980, p. 30, Theorem 5 and its proof
Read-back

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

The statement is a conjunction of two claims about three objects defined in imported modules: δ\deltaδ (exDelta), a cost function ccc (exCost), and a set-valued map Steps\mathrm{Steps}Steps (possibleSteps). Their definitions are in Definitions.Def_MasekPaterson_Necessity_example and Definitions.Def_MasekPaterson_Shared_steps. They were not provided to this read-back and could not be found on disk, so they cannot be unfolded here. The declaration has no explicit binders, hypotheses or typeclass assumptions. Everything it says is about these fixed objects.

  • δ\deltaδ is a function taking two natural numbers i,ji, ji,j and returning a value δi,j\delta_{i,j}δi,j​. The code alone does not show what type that value has.
  • ccc is a specific fixed object that the statement calls a cost.
  • Steps(c)\mathrm{Steps}(c)Steps(c) is a set. The code does not show its element type or how its membership is defined.

First claim (injectivity). Define a map on the natural numbers by

f(k)  =  δk, k+1  −  δk, k,k∈N={0,1,2,… }.f(k) \;=\; \delta_{k,\,k+1} \;-\; \delta_{k,\,k}, \qquad k \in \mathbb{N} = \{0, 1, 2, \dots\}.f(k)=δk,k+1​−δk,k​,k∈N={0,1,2,…}.

The claim is that fff is injective: for all k,k′∈Nk, k' \in \mathbb{N}k,k′∈N, if f(k)=f(k′)f(k) = f(k')f(k)=f(k′) then k=k′k = k'k=k′. Equivalently, the values f(0),f(1),f(2),…f(0), f(1), f(2), \dotsf(0),f(1),f(2),… are pairwise distinct. Here −-− is whatever subtraction the value type of δ\deltaδ carries.

Second claim (infinitude). The set Steps(c)\mathrm{Steps}(c)Steps(c) is not finite. In other words, it is an infinite set in the ordinary cardinality sense.

The two claims are joined only by "and". The statement does not assert that the differences f(k)f(k)f(k) belong to Steps(c)\mathrm{Steps}(c)Steps(c), or that either claim implies the other. It mentions no strings An,BnA^n, B^nAn,Bn, no edit matrix, no parameter nnn, and no count of "at least nnn distinct steps". Any such link lives only in the unseen definitions or in the docstring, not in the asserted proposition.

Degenerate cases. There are no hypotheses, so none can be vacuous or impossible to satisfy. The quantification over kkk includes k=0k = 0k=0, where f(0)=δ0,1−δ0,0f(0) = \delta_{0,1} - \delta_{0,0}f(0)=δ0,1​−δ0,0​. If the value type of δ\deltaδ were N\mathbb{N}N, subtraction would be truncated: f(k)=0f(k) = 0f(k)=0 whenever δk,k+1≤δk,k\delta_{k,k+1} \le \delta_{k,k}δk,k+1​≤δk,k​. In that case injectivity would force this to happen for at most one kkk. Whether that case arises cannot be seen here. Likewise, whether δ\deltaδ or Steps\mathrm{Steps}Steps are built from total-function defaults (division by zero, suprema of empty sets, and so on) depends on definitions not visible to this read-back. The statement's meaning, including whether it is trivially true or false, rests entirely on those definitions.

Human review
  • Endorsed by Shuze Chen · Sep 28, 2026

    Confirmed by the moderator at approval.

  • Endorsed by mikedeng1 · Sep 28, 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