The position skipping proof has been successfully decomposed from a monolithic 3,379-line file into 9 well-organized modules totaling 3,707 lines (9.7% overhead for modularity).
theories/
├── Position_Skipping_Proof.v 569 lines (Main entry point)
├── Auxiliary/
│ ├── Types.v 169 lines (Type definitions)
│ └── Lib.v 969 lines (Core library lemmas)
├── Core/
│ └── Rules.v 105 lines (Rule operations)
├── Invariants/
│ ├── SearchInvariant.v 314 lines (Search invariant)
│ ├── NoMatch.v 381 lines (No-match preservation)
│ └── AlgoState.v 222 lines (Algorithm state)
└── Patterns/
├── PatternHelpers.v 472 lines (Pattern lemmas)
└── PatternOverlap.v 506 lines (Axiom 2 - FULLY PROVEN)
─────────
3,707 lines total
Lines: 569 Purpose: Main entry point that ties all modules together Key Content:
find_first_match_from_skip_onefind_first_match_from_skip_rangefind_first_match_from_skip_early_positionsno_rules_match_before_first_match_preservedno_early_match_preservedapply_rules_seq_opt_start_pos_equivposition_skip_safe_for_local_contexts ✓ PROVENposition_skipping_conditionally_safe ✓ PROVENfinal_position_can_change ✓ PROVENLines: 169 Purpose: Foundational type definitions and predicates Key Content:
wf_rule - Well-formedness predicateposition_dependent_context - Context classificationno_rules_match_before - Multi-rule non-matching predicateno_rules_match_anywhere - Alternative formulationSearchInvariant - Search state invariantAlgoState - Algorithm execution stateno_rules_match_before and no_rules_match_anywhereLines: 969 Purpose: Core library of reusable lemmas Key Content:
nth_error_app_left, nth_error_app_rightnth_error_replace_same_lengthlength_replace_patternnth_error_none_implies_no_pattern_matchphone_mismatch_implies_no_pattern_matchbefore_vowel_context_preservedbefore_consonant_context_preservedafter_vowel_context_preservedafter_consonant_context_preservedfind_first_match properties
find_first_match_fromLines: 105 Purpose: Core operations on rewrite rules Key Content:
can_apply_at_beyond_length - Out-of-bounds checkingapply_rule_at_region_structure - Regional preservation
apply_rule_at_preserves_prefix - Prefix preservationLines: 314 Purpose: SearchInvariant predicate and properties Key Content:
search_invariant_implies_no_matchessearch_invariant_implies_no_matches_anywheresearch_invariant_initsearch_invariant_init_for_rulessearch_invariant_step_single_rulesearch_invariant_step_multi_rulefind_first_match_establishes_invariant_singlefind_first_match_establishes_invariantLines: 381 Purpose: No-match preservation theorems Key Content:
no_new_early_matches_after_transformation ✓ PROVENsingle_rule_no_match_preserved (Axiom 1) ✓ PROVENfind_first_match_in_algorithm_implies_no_earlier_matches ✓ PROVENLines: 222 Purpose: Algorithm state model and maintenance Key Content:
algo_state_maintains_invariant ✓ PROVENfind_first_match_implies_algo_statealgo_state_advance_when_no_matchalgo_state_initalgo_state_restart_after_matchalgo_state_implies_search_invariantLines: 472 Purpose: Pattern matching helper lemmas Key Content:
pattern_matches_at_has_mismatchpattern_has_leftmost_mismatchLines: 506 Purpose: Pattern overlap preservation (Axiom 2) Key Content:
leftmost_mismatch_before_transformation ✓ FULLY PROVEN
pattern_overlap_preservation (Axiom 2) ✓ FULLY PROVEN
All theorems are proven with Qed - no admitted statements remain.
✅ Axiom 1 (single_rule_no_match_preserved): FULLY PROVEN
✅ Axiom 2 (pattern_overlap_preservation): FULLY PROVEN
✅ Main Theorem (position_skip_safe_for_local_contexts): FULLY PROVEN
✅ Conditional Safety (position_skipping_conditionally_safe): FULLY PROVEN
✅ Counterexample (final_position_can_change): PROVEN
Auxiliary/Lib.v provides 969 lines of reusable lemmasCore/Rules.v operations used across all modulesAuxiliary/Types.vPosition_Skipping_Proof.v
├─> Auxiliary.Types
├─> Auxiliary.Lib
├─> Core.Rules
├─> Invariants.SearchInvariant
├─> Invariants.NoMatch
├─> Invariants.AlgoState
├─> Patterns.PatternHelpers
└─> Patterns.PatternOverlap
Patterns.PatternOverlap
├─> Auxiliary.Types
├─> Auxiliary.Lib
├─> Core.Rules
└─> Patterns.PatternHelpers
Invariants.NoMatch
├─> Auxiliary.Types
├─> Auxiliary.Lib
├─> Core.Rules
└─> Patterns.PatternHelpers
Invariants.AlgoState
├─> Auxiliary.Types
├─> Auxiliary.Lib
└─> Core.Rules
Invariants.SearchInvariant
├─> Auxiliary.Types
├─> Auxiliary.Lib
└─> Core.Rules
Patterns.PatternHelpers
├─> Auxiliary.Types
└─> Auxiliary.Lib
Core.Rules
├─> Auxiliary.Types
└─> Auxiliary.Lib
Auxiliary.Lib
└─> Auxiliary.Types
Auxiliary.Types
└─> (base - only depends on stdlib)
To compile all modules in dependency order:
cd docs/verification/phonetic/theories
# Layer 1: Base types
coqc Auxiliary/Types.v
# Layer 2: Core library
coqc Auxiliary/Lib.v
# Layer 3: Core operations
coqc Core/Rules.v
# Layer 4: Pattern helpers and Invariants base
coqc Patterns/PatternHelpers.v
coqc Invariants/SearchInvariant.v
# Layer 5: Advanced invariants
coqc Invariants/AlgoState.v
coqc Invariants/NoMatch.v
# Layer 6: Pattern overlap (Axiom 2)
coqc Patterns/PatternOverlap.v
# Layer 7: Main proof
coqc Position_Skipping_Proof.v
Or use coq_makefile for parallel builds:
coq_makefile -f _CoqProject -o Makefile
make -j$(nproc)
All theorems, lemmas, and corollaries are proven with Qed. The verification is:
| Theorem | Status | Lines | Module |
|---|---|---|---|
single_rule_no_match_preserved | ✅ PROVEN | ~150 | Invariants/NoMatch.v |
pattern_overlap_preservation | ✅ PROVEN | 612 | Patterns/PatternOverlap.v |
leftmost_mismatch_before_transformation | ✅ PROVEN | 172 | Patterns/PatternOverlap.v |
position_skip_safe_for_local_contexts | ✅ PROVEN | ~150 | Position_Skipping_Proof.v |
position_skipping_conditionally_safe | ✅ PROVEN | ~10 | Position_Skipping_Proof.v |
final_position_can_change | ✅ PROVEN | ~15 | Position_Skipping_Proof.v |
The main module includes extraction directives for OCaml:
Recursive Extraction
apply_rules_seq
apply_rules_seq_opt
can_apply_at
position_dependent_context.
This allows empirical testing of the verified algorithms.
The modular decomposition successfully:
The position skipping optimization is formally verified for position-independent contexts, with all proofs complete and rigorous.
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 |