Continue debugging the diagonal crossing integration for Universal Levenshtein Automata (Phase 4).
The fundamental bug was in src/transducer/universal/position.rs in the I-type successor function.
The Bug: Used bit_vector.starts_with_one() to check for matches, which only checks index 0. For universal positions I+offset#errors, the match should be checked at index offset + n.
Why This Matters:
Changed from:
if bit_vector.starts_with_one() { ... }
To:
let match_index = (max_distance as i32 + offset) as usize;
if match_index < bit_vector.len() && bit_vector.is_match(match_index) { ... }
✓ test_accepts_identical ("test" → "test") ✓ test_accepts_deletion ("test" → "tet") ✓ test_accepts_insertion ("test" → "teast") ✓ test_accepts_empty_to_empty ✓ test_accepts_empty_word ✓ test_accepts_to_empty
✗ test_accepts_substitution ("test" → "text") ✗ test_accepts_multiple_edits ("test" → "best") ✗ test_accepts_n1 ("test" → "text" with n=1) ✗ test_accepts_longer_words ("algorithm" → "algorythm")
###Problem All failing tests involve substitutions - cases where the input character doesn't match the word character, requiring both positions to advance with an error.
Attempt 1: Return early when no match at current position
if !bit_vector.is_match(match_index) {
// Generate substitution
successors.push(I+offset#(errors+1));
return successors;
}
Result: Broke insertions (6/10 → 8/10 then back to 6/10)
Attempt 2: Add substitution alongside delete/insert
if match_index < bit_vector.len() && !is_match(match_index) {
// DELETE
successors.push(I+(offset-1)#(errors+1));
// SUBSTITUTE
successors.push(I+offset#(errors+1));
// SKIP-TO-MATCH
...
}
Result: Same 4 substitution tests still failing (6/10)
The issue may be related to when the substitution logic applies. The thesis formulas check the entire bit vector pattern (starts_with_one, is_all_zeros), but we're checking a specific position (match_index).
Possible issues:
src/transducer/universal/position.rs (lines 387-460)
src/transducer/universal/automaton.rs
src/transducer/universal/state.rs
PHASE4_BIT_VECTOR_BUG.md - Analysis of the bit vector position bugPHASE4_STATUS.md - Current status trackingPHASE4_SUBSTITUTION_ANALYSIS.md - Deep analysis of substitution problemAdd detailed tracing for "test" → "text" to see:
Verify subsumption isn't incorrectly removing substitution paths
Check acceptance condition for states with errors > 0
Consider whether the thesis formulas need different adaptation for universal positions
The thesis defines transitions for concrete positions where the bit vector represents a fixed neighborhood. Universal positions use relative offsets which change the semantics. The formulas may need more significant adaptation than just index calculation.
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 |