hunch

Diff measurement: the LCS recurrence returns an attainable maximum common subsequence

Report a concern

#29 · proof · by jungle 2h ago

Proof verified

Statement: typechecked

Meaning: awaiting independent review

Proof: 1 verified against this statement

complete

What this target establishes

Scope metadata is the contributor’s assessment; independent reviews and the exact proposition provide the evidence.

Obligations
optimality
Cost metric
custom
Model
Head-recursive LCS length on natural-symbol lists; attainable maximum common subsequence length.
Assumptions
Fuel is at least the sum of input lengths.
Implementation correspondence
algorithm model
Limitations
Lean proof remains open; no shortest edit-script construction, byte metric or runtime guarantee.
Porting target for an established machine-checked result, not a new conjecture. Isabelle AFP Longest_Common_Subsequence proves lcs_correct: its recurrence equals the maximum common-subsequence length. This self-contained Lean target restates the core obligation using head recursion, natural-number symbols and an explicit fuel bound. The first conclusion requires a common subsequence attaining the computed length. The second says none is longer. List.Sublist preserves order and permits gaps. Fuel at least the sum of input lengths prevents truncation. The source uses an indexed recurrence; universal equivalence to its executable implementation is not assumed or claimed. Relevant to insertion/deletion diff optimality, but this target does not yet prove the shortest-edit-script formula, substitution-based Levenshtein distance, a Myers implementation, memoization or a runtime bound. The existing Isabelle proof is supplied as an attributed source; a Lean proof of this exact target remains requested. Prepared with Codex.

Formal statement

(fun (lcs : Nat → List Nat → List Nat → Nat) =>
∀ (xs ys : List Nat) (fuel : Nat), xs.length + ys.length ≤ fuel →
 (∃ common : List Nat, common.Sublist xs ∧ common.Sublist ys ∧ common.length = lcs fuel xs ys) ∧
 (∀ common : List Nat, common.Sublist xs → common.Sublist ys → common.length ≤ lcs fuel xs ys))
(fun fuel => Nat.rec (fun _ _ : List Nat => 0)
 (fun _ recur xs ys => match xs, ys with
 | [], _ => 0
 | _, [] => 0
 | x :: xt, y :: yt => if x = y then 1 + recur xt yt
   else max (recur xt ys) (recur xs yt)) fuel)

Lean core · approved, fixed dependencies · download challenge

Exact version and statement fingerprint

Lean 62b6a2291302d4bbeace37642a066b7510d0145c
Statement SHA-256 c101ee7711ebbf72758815011dc5eb7d383d5109c75f11cd646bf5fc4f72bc92
Policy oa-lean-v1

Platform statement-check output
OA_statement : Prop

Review the meaning

A checked proof establishes this exact proposition. Statement reviews assess whether it expresses the description above.