Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Lemma 7 — δ_{k,k} = k − μ_k and δ_{k,k+1} = δ_{k+1,k} = 5 + (μ_{k+1} + μ_k)π

Proved
MasekPaterson.Necessity.center_diagonals

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

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

In the §4.1 example, with δi,j=δ(γ,Ai,Bj)\delta_{i,j} = \delta(\gamma, A^i, B^j)δi,j​=δ(γ,Ai,Bj), for every natural number kkk:

δk,k=k−μk;\delta_{k,k} = k - \mu_k;δk,k​=k−μk​;
δk,k+1=δk+1,k=5+(μk+1+μk) π.\delta_{k,k+1} = \delta_{k+1,k} = 5 + (\mu_{k+1} + \mu_k)\,\pi.δk,k+1​=δk+1,k​=5+(μk+1​+μk​)π.

These are the exact values of the edit distances on the main diagonal and on the two adjacent diagonals of the edit matrix. The main diagonal consists of integers, while the adjacent diagonals carry integer multiples of π\piπ plus 555.

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

/-- Lemma 7: for all `k`, (a) `δ_{k,k} = k - μ_k` and
(b) `δ_{k,k+1} = δ_{k+1,k} = 5 + (μ_{k+1} + μ_k) π`. -/
theorem center_diagonals (k : ℕ) :
    exDelta k k = (k : ℝ) - (mu k : ℝ) ∧
    (exDelta k (k + 1) = exDelta (k + 1) k ∧
      exDelta (k + 1) k = 5 + ((mu (k + 1) : ℝ) + (mu k : ℝ)) * Real.pi) := by sorry

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

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

The setting is the specific example: Σ={a,b,c}\Sigma=\{a,b,c\}Σ={a,b,c}, the cost function γ\gammaγ, the sequences A,BA,BA,B, and μi=⌊2⌊i/2⌋/(2π+1)⌋\mu_i=\lfloor 2\lfloor i/2\rfloor/(2\pi+1)\rfloorμi​=⌊2⌊i/2⌋/(2π+1)⌋. Also δi,j=editDist(γ,Ai,Bj)\delta_{i,j}=\mathrm{editDist}(\gamma,A^i,B^j)δi,j​=editDist(γ,Ai,Bj), where editDist is the imported edit distance (not shown) and Ai=A1⋯AiA^i=A_1\cdots A_iAi=A1​⋯Ai​, Bj=B1⋯BjB^j=B_1\cdots B_jBj=B1​⋯Bj​.

For every natural number kkk, all three of the following hold, with real arithmetic:

δk,k=k−μk,\delta_{k,k}=k-\mu_k,δk,k​=k−μk​, δk,k+1=δk+1,k,\delta_{k,k+1}=\delta_{k+1,k},δk,k+1​=δk+1,k​, δk+1,k=5+(μk+1+μk)π.\delta_{k+1,k}=5+\big(\mu_{k+1}+\mu_k\big)\pi.δk+1,k​=5+(μk+1​+μk​)π.

Degenerate cases.

  • The subtraction k−μkk-\mu_kk−μk​ is real, not truncated.
  • At k=0k=0k=0 the claims are δ0,0=0\delta_{0,0}=0δ0,0​=0 (edit distance between two empty lists) and δ0,1=δ1,0=5\delta_{0,1}=\delta_{1,0}=5δ0,1​=δ1,0​=5, since μ0=μ1=0\mu_0=\mu_1=0μ0​=μ1​=0.
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