[wip/levenshtein] Prove DP/recursive equivalence bridge#25
Conversation
|
Companion artifact (separate toolchain) is now published at: This contains the VST/CompCert-side files (levenshtein.v, �erif_levenshtein.v, levenshtein.c, _CoqProject) and build instructions. The split keeps this Crane PR focused on the Rocq/Dune bridge proof files. |
|
I'm trying to keep the tests in a specific format: one Rocq file, one |
Add a new bridge proof file tests/wip/levenshtein/BridgeDP.v that formalizes a loop-structured Wagner-Fischer DP model and proves it computes the same value as levenshtein_computed. BridgeDP adds DP model definitions, cache/row invariants, reverse-orientation machinery, and the final theorem lev_dp_string_eq_levenshtein_computed. Refactor Levenshtein.v by adding reusable lemmas (levenshtein_computed_of_chain, nil_l/nil_r, cons_neq), simplifying mismatch upper-bound lemmas via cons_neq + lia, and updating Nat lemma references to PeanoNat.Nat where needed for current Rocq compatibility. Result is axiom-free (no Admitted/Axiom) and closes the DP↔recursive equivalence in the Crane Rocq test suite.
Merge the DP bridge (Wagner-Fischer model, row specification, reversal argument, and lev_dp_string_eq_levenshtein_computed) into Levenshtein.v after End Levenshtein, keeping one .v file per test folder. Delete BridgeDP.v.
aa3bef0 to
21ac706
Compare
Summary
This PR completes the missing bridge between the dynamic-programming Levenshtein model and Crane's intrinsic recursive model.
It adds a new proof file
tests/wip/levenshtein/BridgeDP.vand refactorstests/wip/levenshtein/Levenshtein.vto expose reusable recurrence lemmas used by the bridge.Why this matters
Before this PR, we had:
Levenshtein.vbut no completed theorem showing they compute the same value for the same inputs.
This PR closes that gap with:
lev_dp_string_eq_levenshtein_computedWhat changed
1) New file:
tests/wip/levenshtein/BridgeDP.vAdds a full DP formalization and bridge proof:
dp_min,inner_loop,process_row,outer_result_runlev_dp_list,lev_dp_stringrow_values,row_lastinner_loop_cont_correctprocess_row_correct_nonemptyouter_result_run_correctchain_append_rightchain_add_last_sourcechain_strip_last_sourcechain_update_last_sourcerev_string,chain_rev_stringlevenshtein_computed_rev_stringlev_spec_list_revlev_dp_string_eq_levenshtein_computed2) Refactor:
tests/wip/levenshtein/Levenshtein.vAdds reusable lemmas and reduces repeated proof patterns:
levenshtein_computed_of_chainlevenshtein_computed_nil_llevenshtein_computed_nil_rlevenshtein_computed_cons_neqlevenshtein_computed_cons_neqand finish withliainstead of re-derivingmin3branch details each timeNat.*references toPeanoNat.Nat.*where needed for current Rocq compatibilityDependency chain (project-level)
Within Crane, this PR establishes:
BridgeDP.v) -> recursive model (Levenshtein.v)In the broader 4-file story discussed during development:
levenshtein-vst/levenshtein.v+levenshtein-vst/verif_levenshtein.v(VST side, separate toolchain)tests/wip/levenshtein/BridgeDP.v+tests/wip/levenshtein/Levenshtein.v(this PR)So this PR contributes the Crane-side bridge artifact and its required recurrence refactor.
Verification
Ran locally (Rocq toolchain used by Crane tests):
coqc -Q /mnt/d/crane/theories Crane -Q /mnt/d/crane/tests/wip/levenshtein '' /mnt/d/crane/tests/wip/levenshtein/Levenshtein.vcoqc -Q /mnt/d/crane/theories Crane -Q /mnt/d/crane/tests/wip/levenshtein '' /mnt/d/crane/tests/wip/levenshtein/BridgeDP.vBoth compile successfully.
Proof hygiene:
AdmittedAxiomDiff summary
tests/wip/levenshtein/BridgeDP.v: new file (+912)tests/wip/levenshtein/Levenshtein.v: +564 / -179