Opening a decoded row selects the correct key evaluator
ProvedExactPatternStream.ImplementationProof.normalized_open_groupstreaming-algorithmsstring-algorithmsword-ram
A caller has decoded the packed representation of a prefix of child labels. Its registers describe the incoming label, counter bank, group arity, and the reserved storage. The program contains the normalized group header at and places its two evaluator bodies at the prescribed entries. Write for the encoded length of a full group key and for the hash width. On every tape the opening code prepares the applicable evaluator as follows.
Both outcomes preserve the decoded trigger, countdown and flags. They satisfy the same memory and stream frame, so a caller can use this transition in either scan phase.
Preamble
import Definitions.Def_ExactPatternStream_StreamingImplementation open ExactPatternStream open ExactPatternStream.ImplementationProof open DynBrooks MachineProof PackedRAM HashProof CounterProof GroupReader
Formal statement
theorem ExactPatternStream.ImplementationProof.normalized_open_group {w σ m n base start e pos : ℕ} {seed : Seeds σ m} {L : Level} {xs : List Label}
{q : TriggerState L.c} {r : Fin (L.c+2)} {Q : Program} {bytes : List Bool} {a : Config w} {arena : Finset ℕ}
{shortBody longBody : ℕ→Program}
(ω : ℕ→BitVec w) (x : Label) (d : GroupDecoded (n:=n) (base:=base) (start:=start) seed L (xs.take pos) q r a bytes)
(geometry : GroupOpenBounds w σ m n base start L arena) (pc : a.pc=e) (site : PatternNormalizedAt Q e shortBody longBody)
(row : TextParsedRow σ m L.i L.c base start (packedLabelWord w σ m L.i x) a.mem)
(stack : PadParameters w (kCnt σ m) base (groupBankOffset σ m start L) (slotBits (kCnt σ m) n) (Nat.clog 2 (L.c+2)) a)
(arity : (a.mem 33).toNat=L.c+2) :
∃ z : Config w, Reach Q ω a z ∧ GroupOpenFrame base start (countPayloadBits σ m n L.i L.c) arena a z ∧
(((L.c+2)*levelBits σ m L.i≤ hashB σ m ∧ z.pc=normalizedShortEntry e ∧
∃ old,(packedShortTrace (w:=w) (n:=n) seed L xs old q r d.done d.spare).Ready base start pos z) ∨
(hashB σ m<(L.c+2)*levelBits σ m L.i ∧ z.pc=normalizedLongEntry e shortBody ∧
(packedLongTrace (w:=w) (n:=n) seed L xs q r d.done d.spare).Ready base start pos z)) := by sorrySource
Derived word-RAM implementation lemma for Gawrychowski, Janczewski, Jin and Nelson, An Improved Streaming Algorithm for Exact Pattern Matching, STOC 2027 submission 1330, §9, Lemma 9.2, p. 29 (PDF p. 30). Accompanying Lean formalization, InProgress/Stage/PatternPassOpenDispatch.lean, lines 8–50.