A packed scan computes the first learned long-key hash
ProvedExactPatternStream.HashProof.first_learned_from_scan_maskedstreaming-algorithmsstring-algorithmsword-ram
At a placed scanner entry , let be valid level labels and the repeat count. The packed header contains seed , the caller registers describe that header, and the size and address bounds provide space for the projection frames and pending jobs. Put , let be its encoded key length, and let be the target hash width. On every coin tape the scanner reaches a state satisfying
Only the designated projection workspace can change in the packed heap. The stream cursors are preserved. At every earlier clock the extra space is at most bits, where is the projection depth and the field coordinate width. This permits the scanner to work beside live records.
Preamble
import Definitions.Def_ExactPatternStream_StreamingImplementation open ExactPatternStream open ExactPatternStream.HashProof open DynBrooks MachineProof PackedRAM CounterProof SoundProof ImplementationProof
Formal statement
theorem ExactPatternStream.HashProof.first_learned_from_scan_masked {P : Program} {w base entry σ m i c start tail R : ℕ}
(site : ScannedLearnedAt P entry) (ω : ℕ→BitVec w) (a : Config w) (pc : a.pc=entry)
(h u v : Label) (goodH : Coded σ m i h) (goodU : Coded σ m i u) (goodV : Coded σ m i v)
(ptr : a.mem 1=BitVec.ofNat w start) (word : (a.mem 2).toNat=w) (heap : (a.mem 3).toNat=base)
(depth : a.mem 10=BitVec.ofNat w (Nat.clog 2 (c+2))) (counter : a.mem 12=BitVec.ofNat w c)
(scale : a.mem 34=BitVec.ofNat w (340*hashB σ m)) (root : a.mem 35=BitVec.ofNat w (if i=0 then bigL σ m else 0))
(labelSize : (a.mem 36).toNat=levelBits σ m i) (prime : (a.mem 32).toNat=hashPrime (hashB σ m))
(head : a.mem 37=packedLabelWord w σ m i h) (rep : a.mem 39=packedLabelWord w σ m i u)
(lastLabel : a.mem 42=packedLabelWord w σ m i v) (count : (a.mem 43).toNat=c)
(nonempty : 1≤ σ) (labelFit : levelBits σ m i≤ w) (safe : 60≤ base) :
let L:=(c+2)*levelBits σ m i
let b:=hashB σ m
let d:=hashRounds L b
let q:=hashQ b
let cap:=countHashBits σ m i c
let frames:=start+cap
let jobs:=frames+(d*(4*q+2)+4*q)
let group:=h::(List.replicate c u++[v])
let region:=insert 37 (insert 56 (groupStartCells w base jobs frames d q)) ∪
projectionGroupCells w b base jobs frames d ∪ Finset.range 60
∀ st : CountedFieldState (HSeed L b) (levelBits σ m i) c R,
HeaderImage a base start (countedCallbackFields (h:=cap) counterRecordSeed tail st) →
4≤ b → b≤ w → b< L → 4*q+2≤ w → q*(2*d)≤ cap →
d*(4*q+2)+4*q+(d+1)*(4*q+2)≤ cap → 2*(L+b+4)<2^w → 2*(c+1)<2^w →
start+cap+cap<2^w → base+(start+cap+cap)/w+1<2^w →
∃ t,let z:=run P ω a t
z.pc=entry+2138 ∧ (z.mem 41).toNat=(BitVec.ofBoolListBE (hashEval L b st.1 (keyOf σ m i group))).toNat ∧
z.input=a.input ∧ z.output=a.output ∧ z.coinPos=a.coinPos ∧
(∀ j,j< frames ∨ jobs+(d+1)*(4*q+2)≤ j → readBit z.mem base j=readBit a.mem base j) ∧
∀ j≤ t,(run P ω a j).written⊆a.written∪region ∧
spaceBits w (run P ω a j)≤ spaceBits w a+2*(d*(4*q+2))+142*w := 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/AlternateScanFrame.lean, lines 225–348, first_learned_from_scan_masked.