The first pattern feed initializes the packed seed cursor
ProvedExactPatternStream.ImplementationProof.first_cursor_from_publicexact-pattern-matchingstreaming-algorithmsword-ram
Under the prescribed width and address bounds, a successful draw of the residual field element and delivery of the first pattern symbol take the public program to instruction 235. The registers hold that symbol, the sampled residue and its modulus. The cache holds the hash prime, block length and packing width, and the paused cursor starts at address 512 with no packed digits. The run preserves the first 174 registers from the state after delivery and writes only below address 512.
Preamble
import Definitions.Def_ExactPatternStream_StreamingImplementation open ExactPatternStream open ExactPatternStream.ImplementationProof open DynBrooks MachineProof SeedRow
Formal statement
theorem ExactPatternStream.ImplementationProof.first_cursor_from_public {σ w : ℕ} (k : ℕ) (P T : List (Fin σ)) (post : Program)
(bank cache paused : ℕ) (low : 174 ≤ bank) (cacheHigh : bank+18 ≤ cache)
(pausedHigh : cache+3 ≤ paused) (reserved : paused+18 ≤ 512)
(hm : 1 ≤ P.length) (lengths : P.length ≤ T.length) (hn : 3 ≤ T.length) (alphabet : σ ≤ T.length^k)
(wide : (8*(64*(k+2)+2))*ell T.length ≤ w) (ω : Tape w) :
let p : ℕ := residualPrime T.length P.length σ
letI : NeZero p := ⟨(residualPrime T.length P.length σ).property.ne_zero⟩
∀ (x : ZMod p) (used : ℕ) (rf : p ≤ 2^w),TapeDraw.readWord (fieldWord p w rf) ω=some (x,used) →
let Q := firstCursorProgram bank cache paused post
let g := w/(2*hashQ (hashB σ P.length))
∃ d,streamState Q P T ω 0=some d ∧
let e := run Q ω (feed d [(streamWords P T).getD 0 0]) 2
∃ t,let f := run Q ω e t
f.pc=235 ∧ f.input=[] ∧ f.output=[] ∧ f.coinPos=used ∧
(f.mem 0).toNat=(P[0]'hm).val ∧ (f.mem 16).toNat=x.val ∧ (f.mem 17).toNat=p ∧
(f.mem cache).toNat=hashPrime (hashB σ P.length) ∧
(f.mem (cache+1)).toNat=blockLen σ P.length ∧ (f.mem (cache+2)).toNat=g ∧
(f.mem (paused+7)).toNat=512 ∧ (f.mem (paused+8)).toNat=g ∧ (f.mem (paused+10)).toNat=0 ∧
(∀ i < 174,f.mem i=e.mem i) ∧ ∀ j ≤ t,(run Q ω e j).written ⊆ Finset.range 512 := by sorrySource
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). Derived implementation lemma first_cursor_from_public in Stage/SeedFirstCursor.lean, line 52.