From a trained pattern to the first text read
ProvedExactPatternStream.ImplementationProof.text_phase_handoffexact-pattern-matchingstreaming-algorithmsword-ram
Let have lengths , where and . At a positive terminal height, suppose the trained pattern storage, terminal probe, digest, modulus and countdown registers describe the seeded build and the placed text-phase code starts with empty input and output. For all sufficiently large word multipliers and every tape, it reaches a completed state at the designated first text read. The state has empty input and output, its coin cursor is unchanged, and its reset rows and terminal reporter satisfy the text-phase initialization conditions. At every clock, including after the read blocks, the write history stays within the trained arena and
Preamble
import Definitions.Def_ExactPatternStream_StreamingImplementation open ExactPatternStream open ExactPatternStream.ImplementationProof open DynBrooks MachineProof PackedRAM CounterProof SoundProof SeedRow OnlineReport CompletenessProof
Formal statement
theorem ExactPatternStream.ImplementationProof.text_phase_handoff (k : ℕ) : ∃ W : ℕ, ∀ cw,W≤ cw → ∃ K : ℕ,
∀ {σ p e read : ℕ} [NeZero p] {Q : Program} (P T : List (Fin σ)) (seed : Seeds σ P.length) (a : ZMod p),
1≤ P.length → P.length≤ T.length → T.length≤2*P.length → 3≤ T.length → σ≤ T.length^k →
let m:=P.length
let n:=T.length
let w:=cw*ell n
let B:=seededBuild P T seed
let h:=topIndex B
let L:=lvl B h
let terminal:=discoverDigest a (.symbol (patternHead L)) (0,0) (patternTail L)
let arena:=trainedParentArena w σ m n B h
0< h → TextPhaseAt Q e read → Q[read]?=some (.read 28) → ∀ (ω : ℕ→BitVec w) (c : Config w)
(payload : ℕ→List Bool) (initial : ℕ→ℕ),
c.pc=e → PatternPassStorage P T seed h c payload initial → c.written⊆arena →
trainingProbeRep (packedLabelWord w σ m h) c terminal.1.1 →
(c.mem 4).toNat=terminal.1.2.1 → (c.mem 5).toNat=terminal.1.2.2.val →
(c.mem 16).toNat=a.val → (c.mem 17).toNat=p → c.mem 8=1 → (c.mem 32).toNat=m-1 →
c.input=[] → c.output=[] → ∃ z,Reach Q ω c z ∧ z.pc=read ∧ IsCompleted Q z ∧ z.input=[] ∧ z.output=[] ∧
z.coinPos=c.coinPos ∧ TextPhaseReady P T seed a payload z ∧ z.written⊆arena ∧
∀ t,(run Q ω c t).written⊆arena ∧ (spaceBits w (run Q ω c t):ℝ)≤ K*Real.logb 2 n*Real.logb 2 (Real.logb 2 n) := 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 in InProgress/Stage/TextPhaseHandoff.lean, lines 39–121, text_phase_handoff.