Finishing a parked long-key hash preserves the caller registers
ProvedExactPatternStream.HashProof.protected_long_digeststreaming-algorithmsstring-algorithmsword-ram
Let a parked projection record contain the state for a group of labels and its hash seed . Assume the key has the prescribed length , the -bit hash fits a word, the projection area fits its addresses, and a 48-word save area beginning at ends before the heap. In any surrounding program the finalizer at entry reaches
Registers through retain their entry values, and the save area retains a copy of the original 48 registers. Stream cursors and heap bits outside the projection frames are preserved. Every write is charged to the save area or the projection cells. This allows the balanced counter to use the same calling convention immediately after hashing.
Preamble
import Definitions.Def_ExactPatternStream_StreamingImplementation open ExactPatternStream open ExactPatternStream.HashProof open DynBrooks MachineProof PackedRAM ImplementationProof SoundProof
Formal statement
theorem ExactPatternStream.HashProof.protected_long_digest {w σ m i c base start save : ℕ} (pre post : Program)
(ω : ℕ→BitVec w) (a : Config w) (pc : a.pc=pre.length) (low : 60≤ save) (safe : save+48≤ base)
(xs : List Label) (x : Label) (args : LongChildArgs a σ m i c base start x)
(fit : ChildProjectionFits w σ m i c base start) :
let b:=hashB σ m
let L:=(c+2)*levelBits σ m i
let Q:=pre++longDigestCall save pre.length++post
∀ seed : HSeed L b,
let row:=(List.ofFn seed).map (fun t=>(t.1.val,t.2.val))
b< L → b≤ w → (keyOf σ m i xs).length=L →
ParkedChild a σ m i c base start row xs →
∃ clocks,let z:=run Q ω a clocks
z.pc=pre.length+896 ∧ (z.mem 41).toNat=(BitVec.ofBoolListBE (hashEval L b seed (keyOf σ m i xs))).toNat ∧
z.input=a.input ∧ z.output=a.output ∧ z.coinPos=a.coinPos ∧
(∀ l<41,z.mem l=a.mem l) ∧ (∀ l<48,z.mem (save+l)=a.mem l) ∧
(∀ j,j< childProjectionFrames σ m i c start ∨ childProjectionEnd σ m i c start≤ j →
readBit z.mem base j=readBit a.mem base j) ∧
(∀ j,60≤ j → j< base → (j< save ∨ save+48≤ j) → z.mem j=a.mem j) ∧
∀ t≤ clocks,(run Q ω a t).written⊆a.written∪(Finset.Ico save (save+48)∪childProjectionCells w σ m i c base start) := by sorrySource
Derived word-RAM implementation lemma for P. Gawrychowski, W. Janczewski, C. Jin and J. Nelson, An Improved Streaming Algorithm for Exact Pattern Matching, STOC 2027 submission 1330, §9, Lemma 9.2, p. 29 (PDF p. 30). The instruction addresses and register conventions are specific to the accompanying Lean formalization, InProgress/Stage/LongChildProtectedFinish.lean, lines 19–98, protected_long_digest.