Last Updated: 2026-05-27 (weighted articulatory distance + value-yielding query verification) Session: Phase 3 - I-type complete, M-type next; G4/G9 verification added (see 2026-05-27 update) Token Usage: 84k/200k (42%)
Completed: Phases 1 & 2 (Foundation + Invariants), Phase 3 I-Type Operations ✅ In Progress: Phase 3 M-Type Operations Achievements: 26 theorems proven across 4 files, 0 bugs found, 3 simplifications identified
docs/verification/articulatory/theories/FeatureDistance.v was generalized to a FeatureWeights
record (mirroring the Rust FeatureDistanceWeights): symmetry and identity hold for all weights;
non-negativity, bound-by-weight-sum, and per-dimension monotonicity hold for non-negative
weights; the standard-weight 0 <= d <= 1 bound is recovered as a corollary. A faithful
7-dimension model (vowel path + .min(1.0) cap via Qmin) is added in FeatureDistanceWeighted.v.
Both files are admission-free and build under the light profile.Transducer::query_values) is modeled in
docs/verification/tla/ValueYieldingQuery.tla and TLC-checked (ValueCorrectness, Soundness,
NoValuelessYielded, DedupInv, CompletenessInv, termination); evidence in
docs/verification/tla/states/tlc-results-2026-05-27.txt. Cross-validated by Rust property tests.triangle_b_t_k_tight). Stale "triangle failure" / "1
Admitted" wording in FINDINGS_LEDGER.md and VERIFICATION_IMPROVEMENTS.md has been corrected.docs/verification/FINDINGS_LEDGER.md Finding 16 for the full hypothesis→experiment→result record.File: rocq/liblevenshtein/Core.v (585 lines, 53,419 bytes compiled)
Theorems Proven:
subsumes_irreflexive: ∀p, ¬(p ⊑ p)subsumes_transitive: p₁⊑p₂ ∧ p₂⊑p₃ → p₁⊑p₃subsumes_variant_restriction: variant(p₁)≠variant(p₂) → ¬(p₁⊑p₂)subsumes_antisymmetric: p₁⊑p₂ ∧ p₂⊑p₁ → False (derived)Documentation: docs/formal-verification/proofs/01_subsumption_properties.md (600+ lines)
Key Result: Subsumption is a strict partial order, justifying anti-chain state minimization.
Git Commit: 5da8801 - "feat(formal-verification): Phase 1 - Foundational subsumption proofs"
File: rocq/liblevenshtein/Invariants.v (600 lines, 41,700 bytes compiled)
Theorems Proven (13 total):
new_i_correct, new_m_correct, new_i_transposing_correct, new_m_transposing_correct, new_i_splitting_correct, new_m_splitting_correcti_invariant_decidable, m_invariant_decidablevalid_position_errors_bounded, valid_i_offset_bounded, valid_i_reachable, i_zero_errors_on_diagonali_zero_errors_on_diagonalDocumentation: docs/formal-verification/proofs/02_position_invariants.md (600+ lines)
Key Result: All position constructors maintain invariants; invariant checking is computable.
Git Commit: 49561bd - "feat(formal-verification): Phase 2 - Position constructor correctness"
Completed: Operations.v ✅, Transitions.v (I-type) ✅ Next: Transitions.v (M-type), Documentation, Property Tests
File: rocq/liblevenshtein/Operations.v (~340 lines, 13,762 bytes compiled)
Definitions:
StandardOperation: Inductive type (Match, Delete, Insert, Substitute)operation_cost: Cost semantics (0 for match, 1 for others)consume_word, consume_query: Consumption behavioroffset_change: Offset delta per operationCharacteristicVector: Axiomatized (like Rholang approach)has_match: Match checking predicateLemmas Proven (6):
match_is_free: Only match costs 0non_match_costs_one: Other ops cost 1only_delete_moves_left: Only delete changes offsetoperation_consumes_something: All ops consume ≥1 charcost_relates_to_match: Cost 0 ⟺ Matcherror_op_needs_budget: Error ops need budgetStatus: ✅ Compiled successfully, ready for use in Transitions.v
Git Commit: 28f041b - "feat(formal-verification): Phase 3 - Operations.v and status documentation"
File: rocq/liblevenshtein/Transitions.v (515 lines, 30,700 bytes compiled)
Inductive Relations Defined:
i_successor: Successor relation for I-type positions with 4 standard operations
ISucc_Match: Requires has_match, preserves offset and errorsISucc_Delete: Requires errors < n and offset > -n, offset decreases, errors increaseISucc_Insert: Requires errors < n, preserves offset, errors increaseISucc_Substitute: Requires errors < n, preserves offset, errors increaseTheorems Proven (7 for I-type):
i_match_preserves_invariant: Match transitions preserve i_invarianti_delete_preserves_invariant: Delete transitions preserve i_invariant (complex proof with case analysis)i_insert_preserves_invariant: Insert transitions preserve i_invarianti_substitute_preserves_invariant: Substitute transitions preserve i_invarianti_successor_preserves_invariant: ALL I-type operations preserve invariants (main theorem)i_successor_cost_correct: Error accounting matches operation costs exactlyKey Proof Techniques:
replace tactic for S n = n + 1Findings (see FINDINGS.md):
Status: ✅ All I-type proofs complete, compiles with 0 Admitted
Git Commit: c696c0a - "feat(formal-verification): Phase 3 - I-type transitions with complete proofs"
Current: I-type complete (515 lines) Target: Add M-type relations and proofs (~400-500 more lines)
M-type successor relation to define (different offset semantics!):
Inductive m_successor : Position -> StandardOperation ->
CharacteristicVector -> Position -> Prop :=
| MSucc_Match : forall offset errors n cv,
has_match cv ... ->
(errors <= n)%nat ->
m_successor
(mkPosition VarMFinal offset errors n None)
OpMatch
bv
(mkPosition VarINonFinal offset errors n None)
| ISucc_Delete : forall offset errors n bv,
(errors < n)%nat ->
offset > -Z.of_nat n -> (* BUG CHECK: Need this? *)
i_successor
(mkPosition VarINonFinal offset errors n None)
OpDelete
bv
(mkPosition VarINonFinal (offset - 1) (S errors) n None)
| ISucc_Insert : (* Similar pattern *)
| ISucc_Substitute : (* Similar pattern *)
Theorem i_successor_preserves_invariant :
forall p op bv p',
i_invariant p ->
i_successor p op bv p' ->
i_invariant p'.
(* Prove for each operation separately *)
Lemma i_match_preserves_invariant : ...
Lemma i_delete_preserves_invariant : ...
Lemma i_insert_preserves_invariant : ...
Lemma i_substitute_preserves_invariant : ...
Theorem i_successor_cost_correct :
forall p op bv p',
i_successor p op bv p' ->
errors p' = (errors p + operation_cost op)%nat.
Same structure for M-type positions:
m_successor inductive relationm_successor_preserves_invariant theoremm_successor_cost_correct theoremLocation: src/transducer/generalized/position.rs:273-276 (I-type)
Issue: Rust allows offset > errors when errors == 0 for fractional-weight operations
Status: NOT proven in Coq (Phase 3b extension)
Action: Document as unproven extension, add warning comments
Location: src/transducer/generalized/position.rs:436-439 (I-splitting)
Issue: Uses M-type subsumption logic not in formal model
Status: Implementation more complex than proven spec
Action: Either prove necessity or simplify to match Coq
Issue: subsumes_transitive has no property test validating it
Status: Critical for anti-chain algorithm, needs test
Action: Add property test in Phase 3
Delete at left boundary
successors_i_type verify offset > -n before delete?state.rs:297-314offset > -Z.of_nat n preconditionOperations at error budget limit
errors = max_distance, are error ops correctly blocked?errors < n for error opsMatch index calculation
(offset + n) the correct index for characteristic vector?state.rs:266 (I-type), state.rs:570 (M-type)Insert offset handling
state.rs:315-329offset' = offsetCurrent signature (state.rs:238):
fn successors_i_type(
offset: i32,
errors: u8,
operations: &[OperationType],
bit_vector: &CharacteristicVector,
max_distance: u8,
full_word: &str, // ⚠️ Potentially extraneous
word_slice: &str, // ⚠️ Redundant with full_word?
input_char: char,
) -> Vec<GeneralizedPosition>
Questions for validation:
full_word actually used? Or just for debugging?word_slice be derived from full_word + offset?Action: After proving minimal preconditions in Coq, compare with Rust params
Pattern observed:
if errors < max_distance {
let new_errors = errors + 1;
if new_errors <= max_distance { // ⚠️ Redundant?
// create successor
}
}
From arithmetic: errors < n ⟹ errors + 1 ≤ n
Action: If invariant proves this, replace second check with debug_assert!
For each proven theorem:
| Coq Theorem | Location | Rust Code | Location | Property Test | Status |
|---|---|---|---|---|---|
new_i_correct | Invariants.v:176 | new_i() | position.rs:266 | position.rs:566 | ⚠️ Relaxed |
subsumes_irreflexive | Core.v:275 | subsumes() | subsumption.rs:62 | subsumption.rs:208 | ✅ Match |
subsumes_transitive | Core.v:306 | (implied) | anti-chain logic | (missing) | ⚠️ Need test |
| (more to come in Phase 3) |
Core.v (Phase 1) - 585 lines, compiledInvariants.v (Phase 2) - 600 lines, compiledOperations.v (Phase 3) - 340 lines, compiledTransitions.v (Phase 3) - NEXT TO CREATE_CoqProject - Build configurationREADME.md - Project overview (1300+ lines)proofs/01_subsumption_properties.md (600+ lines)proofs/02_position_invariants.md (600+ lines)proofs/03_standard_operations.md - NEXT TO CREATEVALIDATION_MATRIX.md - TO CREATEDISCREPANCIES.md - TO CREATESIMPLIFICATION_OPPORTUNITIES.md - TO CREATESimply start a new conversation in Claude Code. The git repository state is preserved.
I'm continuing formal verification of Levenshtein automata. We've completed
Phases 1-2 (subsumption + invariants). Phase 3 is in progress - Operations.v
is done, now need to create Transitions.v with successor relations and
invariant preservation proofs.
Please read: docs/formal-verification/STATUS.md for current state.
Key focus: As we prove successor functions correct, proof failures will
reveal bugs. Document all bugs found, identify simplification opportunities,
and create property tests for proven theorems.
(* Create Transitions.v starting with: *)
From Stdlib Require Import ZArith Arith Lia Bool.
Require Import Core.
Require Import Invariants.
Require Import Operations.
(* Define i_successor inductive relation *)
(* Start with Match operation, prove preservation *)
(* Then Delete, Insert, Substitute *)
(* Look for bugs in preconditions *)
# Verify all previous work compiles
cd rocq/liblevenshtein
coqc -R . LevensteinAutomata Core.v
coqc -R . LevensteinAutomata Invariants.v
coqc -R . LevensteinAutomata Operations.v
# All should succeed
# Check git status
git log --oneline -5
# Should see Phase 1 and Phase 2 commits
# Compile individual files
cd /home/dylon/Workspace/f1r3fly.io/liblevenshtein-rust/rocq/liblevenshtein
coqc -R . LevensteinAutomata Core.v
coqc -R . LevensteinAutomata Invariants.v
coqc -R . LevensteinAutomata Operations.v
# Compile Transitions.v (when created)
coqc -R . LevensteinAutomata Transitions.v
When Phase 3 is complete, we should have:
✅ Operations.v compiled (13,762 bytes) - DONE ⏳ Transitions.v compiled (~40,000+ bytes) - NEXT ⏳ 15+ theorems proven (successor preservation + cost correctness) ⏳ 3+ bugs discovered and documented ⏳ 3+ simplification opportunities identified ⏳ 10+ property tests added ⏳ Complete validation matrix ⏳ Documentation: 03_standard_operations.md (700+ lines)
docs/research/weighted-levenshtein-automata/README.md - Part I, IIsrc/transducer/generalized/position.rs - Position constructorssrc/transducer/generalized/state.rs:238-890 - Successor functionssrc/transducer/generalized/subsumption.rs - Subsumption implementationsrc/transducer/operation_type.rs - Operation definitionstests/proptest_comprehensive.rs - Property-based teststests/proptest_automaton_distance_cross_validation.rs - Oracle testingsrc/transducer/generalized/position.rs:562-784 - Constructor testsEnd of Status Report
This document should contain everything needed to resume Phase 3 with full context.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |