Resetting the trained text stack within the charged arena
ProvedExactPatternStream.ImplementationProof.reset_trained_text_stackexact-pattern-matchingstreaming-algorithmsword-ram
Fix an alphabet-growth exponent . Consider inputs with , , and . At every sufficiently large word multiplier , there is a uniform for resetting a stack of any trained height up to the top of the seeded build. Start at the reset routine with its scan registers initialized, a valid packed header and correctly sized payloads inside the trained arena. On every tape the machine reaches the end of the routine with the reset rows in memory and the final bit pointer and level index in their specified registers. Input, output, coin position, memory bits beyond the payload and protected caller registers are preserved. At each clock through the return, the written cells stay in the trained arena and satisfy
Preamble
import Definitions.Def_ExactPatternStream_StreamingImplementation open ExactPatternStream open ExactPatternStream.ImplementationProof open DynBrooks MachineProof PackedRAM SeedRow
Formal statement
theorem ExactPatternStream.ImplementationProof.reset_trained_text_stack (k : ℕ) : ∃ W : ℕ, ∀ cw,W≤ cw → ∃ K : ℕ,
∀ {σ : ℕ} (P T : List (Fin σ)) (seed : Seeds σ P.length),
1≤ P.length → P.length≤ T.length → 3≤ T.length → σ≤ T.length^k →
∀ h,h≤ topIndex (seededBuild P T seed) →
let m:=P.length
let n:=T.length
let B:=seededBuild P T seed
let counts:=trainedCounts B
let w:=cw*ell n
let base:=promotionHeapBase w σ m
let limit:=trainedHeapBits σ m n B h
let arena:=trainedParentArena w σ m n B h
∀ {Q : Program} {e : ℕ},ResetStackAt Q e → ∀ (ω : ℕ→BitVec w) (payload : ℕ→List Bool) (a : Config w),
a.pc=e → (a.mem 55).toNat=h → TextResetScanRegs a σ m n 0 base 0 →
a.mem 53=BitVec.ofNat w (levelBits σ m 1) →
(∀ j< h,(payload j).length=countPayloadBits σ m n j (counts j)) →
HeaderImage a base 0 (countRecordHeap h counts payload) → a.written⊆arena →
∃ t,let z:=run Q ω a t
z.pc=e+192 ∧ z.input=a.input ∧ z.output=a.output ∧ z.coinPos=a.coinPos ∧
HeaderImage z base 0 (countRecordHeap h counts (resetRowsFrom w σ m h 0 counts payload)) ∧
(z.mem 1).toNat=limit ∧ (z.mem 14).toNat=h ∧
(∀ j,limit≤ j → readBit z.mem base j=readBit a.mem base j) ∧
(∀ r,57≤ r → r< base → z.mem r=a.mem r) ∧
∀ s≤ t,(run Q ω a s).written⊆arena ∧
(spaceBits w (run Q ω a s):ℝ)≤ 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/TextLaneStackRate.lean, lines 62–106, reset_trained_text_stack.