Documentation

CslibFrontier.Algorithms.WordRAM.AhoCorasick.Layout

Word-RAM Memory and Register Layout for Aho–Corasick #

Base addresses (Input.maxS through Input.outBase), register aliases Reg.* over Fin 26, and the register-layout invariant LayoutInv preserved across all four phases of searchCode.

This module stays independent of the pure trie and BFS models (TrieModel, BFSModel, BFSCorrect) so Layout and Code build in parallel with the pure proof layers.

Main definitions #

Main results #

Word-RAM register and memory layout (Fin 26, Basis.standard) #

Upper bound on the number of trie states (totalPatternLen inp.patterns + 1).

Base word address of the input text array inside the serialized Word-RAM memory.

Base address of the flat maxS × σ array-trie goto table.

Base address of the flat maxS × σ deterministic next-move (delta) table.

Base address of the maxS-word failure-link array.

Base address of the maxS-word state-depth array.

Base address of the maxS-word terminal-state indicator array.

Base address of the maxS-word linked output-chain head array.

Base address of the maxS-word linked output-chain next array.

Base address of the maxS-word BFS FIFO queue array.

Base address of the length-prefixed output list buffer.

@[reducible, inline]

Alphabet size register σ.

@[reducible, inline]

Keyword count register |P|.

@[reducible, inline]

Total keyword length register ‖P‖.

@[reducible, inline]

Text length register |t|.

@[reducible, inline]

Maximum trie state count register maxS = ‖P‖ + 1.

@[reducible, inline]

Base address register for the serialized keyword array (5).

@[reducible, inline]

Base address register for the text array (Input.textBase).

@[reducible, inline]

Base address register for the goto table (Input.trieBase).

@[reducible, inline]

Base address register for the next-move table (Input.deltaBase).

@[reducible, inline]

Base address register for the failure-link array (Input.failBase).

@[reducible, inline]

Base address register for the state-depth array (Input.depthBase).

@[reducible, inline]

Base address register for the terminal-state array (Input.termBase).

@[reducible, inline]

Base address register for the output-chain head array (Input.outHeadBase).

@[reducible, inline]

Base address register for the output-chain next array (Input.outNextBase).

@[reducible, inline]

Base address register for the BFS FIFO queue (Input.queueBase).

@[reducible, inline]

Constant-zero register (0).

@[reducible, inline]

Constant-one register (1).

@[reducible, inline]

Scratch register holding the current state counter or automaton state.

@[reducible, inline]

Scratch register r1 (Fin 26).

@[reducible, inline]

Scratch register r2 (Fin 26).

@[reducible, inline]

Scratch register r3 (Fin 26).

@[reducible, inline]

Scratch register r4 (Fin 26).

@[reducible, inline]

Scratch register r5 (Fin 26).

@[reducible, inline]

Scratch register r6 (Fin 26).

@[reducible, inline]

Scratch register r7 (Fin 26).

Invariant asserting that the 18 read-only layout registers (0..17) hold inp's constants and workspace base addresses.

theorem Cslib.Algorithms.WordRAM.AhoCorasick.LayoutInv.of_preserves {inp : Input} {x y : WordRAM.Data 26} {w t : ℕ} {c : WordRAM.Code WordRAM.Basis.standard 26} (hL : LayoutInv inp x) (he : WordRAM.ExecWithin w c x y t) (hk : 18 ≤ c.writeStart := by decide) :
LayoutInv inp y