Instruction addresses in the public pattern loop
ProvedExactPatternStream.ImplementationProof.public_pattern_loop_layoutexact-pattern-matchingstreaming-algorithmsword-ram
For any pattern sweep, cache initializer, text continuation and optional raw exit, the public loop contains its initial promotion program, training input, sweep, lock sampler, phase dispatch and cache initialization at the specified addresses. The back edge jumps to instruction 3310 and the remaining instructions are exactly the supplied text continuation.
Preamble
import Definitions.Def_ExactPatternStream_StreamingImplementation open ExactPatternStream open ExactPatternStream.ImplementationProof open DynBrooks MachineProof PackedRAM CounterProof HashProof SoundProof OnlineReport SeedRow MeasureTheory
Formal statement
theorem ExactPatternStream.ImplementationProof.public_pattern_loop_layout (noChange : ℕ) (sweep cacheInit text : Program) (rawExit : Option ℕ := none) :
let callback:=3312+sweep.length
let dispatch:=callback+2858
let setup:=dispatch+4
let trained:=setup+cacheInit.length+1
let Q:=publicPatternLoop noChange sweep cacheInit text rawExit
(∃ tail,Q=firstPublicAdvanceProgram noChange setup (rawExit.getD trained) (trainingInputCode++sweep++tail)) ∧
(∀ i < 2,Q[3310+i]?=trainingInputCode[i]?) ∧
(∀ i < sweep.length,Q[3312+i]?=sweep[i]?) ∧
(∀ i< trainingDoneOps.length,Q[callback+i]?=trainingDoneOps[i]?.map Assignment.instr) ∧
(∀ i<3,Q[callback+trainingDoneOps.length+i]?=(trainingLockCode dispatch (callback+19))[i]?) ∧
LockAllocatorAt Q (callback+19) ∧
(∀ i<4,Q[dispatch+i]?=(patternPhaseCode 3310 trained)[i]?) ∧
(∀ i< cacheInit.length,Q[setup+i]?=cacheInit[i]?) ∧
Q[setup+cacheInit.length]?=some (.jmp 3310) ∧
∀ i,Q[trained+i]?=text[i]? := 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 public_pattern_loop_layout in InProgress/Stage/PublicPatternCodeSites.lean, line 11.