A last-symbol first change gives a one-level pattern hierarchy
ProvedExactPatternStream.ImplementationProof.final_first_change_levelexact-pattern-matchingstreaming-algorithmsword-ram
Let a nonconstant pattern and text have lengths . Assume the first symbol of different from occurs at index . For every hierarchy seed , the seeded build satisfies
Thus the first promotion consumes all available pattern events.
Preamble
import Definitions.Def_ExactPatternStream_StreamingImplementation open ExactPatternStream open ExactPatternStream.ImplementationProof open DynBrooks MachineProof PackedRAM CounterProof HashProof SoundProof OnlineReport SeedRow
Formal statement
theorem ExactPatternStream.ImplementationProof.final_first_change_level {σ : ℕ} (P T : List (Fin σ)) (seed : Seeds σ P.length)
(hm : 1≤ P.length) (mn : P.length≤ T.length) (twice : T.length≤2*P.length)
(nonconstant : P≠List.replicate P.length (P[0]'hm))
(last : P.findIdx (fun a=> decide (a≠P[0]'hm))+1=P.length) :
let B:=seededBuild P T seed
topIndex B=1 ∧ patternTail (lvl B 1)=[] := 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/FirstLastTraining.lean, lines 36–59, final_first_change_level.