The projection and balanced counter advance on the same child
ProvedExactPatternStream.ImplementationProof.long_child_counterstreaming-algorithmsstring-algorithmsword-ram
For pattern and text lengths , fix a seed, a nonfinal level of its hierarchy, and a valid child of either expanded parse stream. Suppose its parked projection represents the preceding children of its group, the counter slots represent their values, and the register, width, address and disjoint-workspace bounds hold. If is the preceding group prefix, the child, and the balanced counter slots after this child, the block at reaches
The 48 caller registers are restored and retained in the save area. The stream cursors agree at entry and exit. All runs up to the return obey the stated write bound on the projection, save and counter work areas. The two summaries therefore refer to the same ordinal of the same group.
Preamble
import Definitions.Def_ExactPatternStream_StreamingImplementation open ExactPatternStream open ExactPatternStream.ImplementationProof open DynBrooks MachineProof PackedRAM HashProof CounterProof SoundProof CompletenessProof
Formal statement
theorem ExactPatternStream.ImplementationProof.long_child_counter {σ w base start save stack : ℕ} (P T : List (Fin σ))
(seed : Seeds σ P.length) (hm : 1≤ P.length) (hmn : P.length≤ T.length) (hn : T.length≤2*P.length)
(j : ℕ) (below : j< topIndex (seededBuild P T seed))
(pre post : Program) (ω : ℕ→BitVec w) (low : 60≤ save) (safe : save+48≤ base) :
let m:=P.length
let n:=T.length
let L:=lvl (seededBuild P T seed) j
let g:=L.c+2
let dt:=Nat.clog 2 g
let k:=kCnt σ m
let width:=slotBits k n
let last:=stack+dt*width
let Q:=pre++longChildCounterCode save pre.length++post
∀ (S : List ParseTree) (A : List Bool), (S=L.P ∧ A=L.AP) ∨ (S=L.T ∧ A=L.AT) →
let Z:=payload S A L.i L.w L.u L.c L.v
∀ (r : ℕ), (hr : r< Z.length) →
let x:=(Z[r]'hr).2.label
let idx:=r%g
let labels:=counterChildLabels L S A (r/g)
let prior:=labels.take idx
let following:=prior++[x]
let vals:=payloadCounterInputs σ m L S A (r/g)
let state:=fun u=>(vals.take u).foldl (slotsRead k n) (emptySlotStack k n dt)
let slots:=fun u=>(state u).1++[(state u).2]
let slotsNext:=slots (Nat.succ idx)
∀ (seeds : List (ℕ×ℕ)),seeds.length=childProjectionDepth σ m L.i L.c →
∀ a : Config w, a.pc=pre.length → LongChildArgs a σ m L.i L.c base start x →
ChildProjectionFits w σ m L.i L.c base start →
ParkedChild a σ m L.i L.c base start seeds prior →
childProjectionEnd σ m L.i L.c start≤ stack →
PadParameters w k base stack width dt a → SlotsAt a.mem base stack width (slots idx) →
(a.mem 38).toNat=expBits σ m → (a.mem 39).toNat=σ → (a.mem 40).toNat=L.i →
4*m<2^w → width+1≤ w → n<2^w → 2*dt<2^w → last<2^w → base+last/w+1<2^w →
LongChildCounterResult Q ω a σ m L.i L.c base start pre.length save stack last width seeds following slotsNext := 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/LongChildCounter.lean, lines 37–160, long_child_counter.