Date: 2025-11-13 Status: Analyzing bit vector indexing semantics
Tests are still failing after initial fix. Need to reconsider the interpretation of b[k] indexing from Mitankin's thesis.
For transposition variant χ = t with error limit e:
Usual State:
δ^D,t_e(i#e, b) = δ^D_e(i#e, b) ∪ {(i+1)#(e+1)_t} if b[1] = 0 ∧ e < n, else δ^D_e(i#e, b)
Transposing State:
δ^D,t_e(i#e_t, b) = {(i+2)#e} if b[1] = 1, else ∅
The characteristic vector β(x, w') encodes matches at each position. The notation b[k] refers to index k in the bit vector.
For position i#e:
i - eb[0] corresponds to word position i - eb[k] corresponds to word position i - e + kIn our implementation:
match_index = n + offset checks position b[n+offset]i#e with offset = i-e, this checks b[n + i - e]b[1] CheckWhen Mitankin writes b[1], this means "check position 1 in the bit vector".
For position i#e:
i - eb[0] maps to index n + offset in our implementationb[1] maps to index n + offset + 1 in our implementationI-type Usual State (line 221): ✅ CORRECT
let next_match_index = (max_distance as i32 + offset + 1) as usize;
if next_match_index < bit_vector.len()
&& !bit_vector.is_match(next_match_index) // Checks b[1] = 0
I-type Transposing State (line 242): ❓ NEEDS REVIEW
let match_index = (max_distance as i32 + offset) as usize;
if match_index < bit_vector.len() && bit_vector.is_match(match_index) // Checks b[0] = 1???
M-type Usual State (line 282): ❌ WRONG
let match_index = (max_distance as i32 + offset) as usize;
if match_index < bit_vector.len()
&& !bit_vector.is_match(match_index) // Should check b[1] = 0, not b[0] = 0
M-type Transposing State (line 303): ❓ NEEDS REVIEW
let match_index = (max_distance as i32 + offset) as usize;
if match_index < bit_vector.len() && bit_vector.is_match(match_index) // Checks b[0] = 1???
The issue is with the Transposing state interpretation. When we enter the Transposing state, we create a position with offset+1 and errors+1:
// From Usual state (line 228-233):
UniversalPosition::new_i_with_state(
offset + 1, // NEW offset
errors + 1, // NEW errors
max_distance,
TranspositionState::Transposing,
)
So when we're in the Transposing state with this new position:
(i+1)#(e+1)_t(i+1) - (e+1) = i - eWait, that can't be right. Let me reconsider...
Actually, in the I^ε conversion:
i#e is stored as I+offset where offset = i - 1Let me trace through "ab" → "ba" manually:
Initial State: {I+0#0_usual}
Process input[0] = 'b':
Hmm, I need to better understand the bit vector construction and window semantics.
The fundamental issue might be that I don't fully understand the bit vector window and indexing semantics. I need to:
bit_vector.rss_n(w, k) (the subword window) actually containsb[k] to the correct implementation indexsrc/transducer/universal/bit_vector.rs to understand constructionThe most suspicious issue is that in Transposing state, I'm checking b[0] when the thesis says b[1]. This suggests the Transposing state might also need to check match_index + 1.
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 |