Lemma 8.5 — soundness:
ProvedExactPatternStream.lemma_8_5fingerprintingp2o-gran-per-chapterp2o-plan-paperp2o-strengthenedp2o-v1pattern-matchingrandomized-algorithmsstreaming-algorithmsstring-algorithms
Let be the output of Algorithm 2. Then for all sufficiently large ,
This, with Lemma 5.2, gives all the correctness of the algorithm, separately from its implementation.
Differences from the source:
- encoding: "for all sufficiently large ", → : and ; reason: means every polynomial bound
- reading: → ; reason: the stronger reading among bases , and the base of §7
- encoding: a set of positions → a
Finset ℤ, and cast toℤ; reason: a negative candidate must count as an error - generalization: "Choose a prime with " → every prime ; reason: the bound on is used only for space (decision 9), and the source choice is included
- encoding: sampled once level is known → one independent uniform block per level, read through a prefix (
Seeds); reason: the same law: a prefix of an independent uniform block is uniform and independent of the lower levels - encoding: "fix any injective" codes , → the fixed binary codes of
SeededHash; reason: the source fixes one code, and nothing depends on the choice - encoding: →
Fin σ, shifted by one in the stream and in ; reason: the same alphabet
Preamble
import Mathlib import Definitions.Def_ExactPatternStream_Strings import Definitions.Def_ExactPatternStream_Pad import Definitions.Def_ExactPatternStream_ParseTree import Definitions.Def_ExactPatternStream_Build import Definitions.Def_ExactPatternStream_LinearMaps import Definitions.Def_ExactPatternStream_HashFamily import Definitions.Def_ExactPatternStream_Counters import Definitions.Def_ExactPatternStream_SeededHash
Formal statement
namespace ExactPatternStream
/-- Gawrychowski, Janczewski, Jin, Nelson, *An Improved Streaming Algorithm for Exact Pattern Matching* (preprint, STOC 2027 submission, sha256 351218cb…), Lemma 8.5, p.26 (PDF 27).
Soundness: let `M` be the output of Algorithm 2. For all sufficiently large `m`, `Pr[M ⊄ Occ(P, T)] ≤ (log m)^{-2}`.
**Formalization Note.** "Sufficiently large" is `∀ k, ∃ C` with `|Σ| ≤ n^k`, the paper's `|Σ| ≤ n^{O(1)}`. The probability is over the recursive seeds and an independent uniform `a_R`, for every prime `p_R > 2^{4𝓛}`. `P, T` are fixed before the seeds. `M` is a set of integers, so a negative candidate counts as an error. `log = log₂`. -/
theorem lemma_8_5 : ∀ k : ℕ, ∃ C : ℕ, ∀ (σ : ℕ) (P T : List (Fin σ)) (pR : ℕ) [Fact pR.Prime],
C ≤ P.length → P.length ≤ T.length → T.length ≤ 2 * P.length → σ ≤ T.length ^ k →
2 ^ (4 * bigL σ P.length) < pR →
unifProb (fun s : Seeds σ P.length × ZMod pR => ¬ seededMatch P T s ⊆ occZ P T) ≤
((Real.logb 2 P.length) ^ 2)⁻¹ := by sorry
end ExactPatternStream
Source
Gawrychowski, Janczewski, Jin, Nelson, An Improved Streaming Algorithm for Exact Pattern Matching (preprint, STOC 2027 submission, sha256 351218cb…), Lemma 8.5, p.26 (PDF 27)
Human review
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.