Lemma 7.5 — : accuracy and bits
ProvedExactPatternStream.lemma_7_5fingerprintingp2o-gran-per-chapterp2o-plan-paperp2o-v1pattern-matchingrandomized-algorithmsstreaming-algorithmsstring-algorithms
For every , there is a deterministic one-pass algorithm that, on precision- counters , returns a precision- counter with
If for every , then . If with , it uses working bits.
This keeps a node's approximate weight in its label at a small cost in bits.
Differences from the source:
- reading: "deterministic one-pass algorithm … uses working bits" →
sumKfor the accuracy clauses; for the space clause, one finite-stateEvaluatorper with that many state bits, one update per counter; reason: the source counts working space and does not fix a machine at this level; the goal's single program is the job of Lemma 9.2 - encoding: unspecified → real numbers; reason: the use has integers, which are real
- encoding: → one absolute before all variables, with ; reason: the same bounds up to a constant
Preamble
import Mathlib import Definitions.Def_ExactPatternStream_LinearMaps import Definitions.Def_ExactPatternStream_Strings import Definitions.Def_ExactPatternStream_HashFamily import Definitions.Def_ExactPatternStream_Counters
Formal statement
namespace ExactPatternStream
/-- Gawrychowski, Janczewski, Jin, Nelson, *An Improved Streaming Algorithm for Exact Pattern Matching* (preprint, STOC 2027 submission, sha256 351218cb…), Lemma 7.5, p.20 (PDF 21).
`Sum_k` on `r ≥ 2` precision-`k` counters returns a precision-`k` counter `z` with `val(z) ≤ Σ val(z_j) ≤ exp(⌈log₂ r⌉ 2^{-k}) val(z)`; if `val(z_j) ≤ x_j ≤ exp(θ) val(z_j)` for every `j`, then `val(z) ≤ Σ x_j ≤ exp(θ + ⌈log₂ r⌉ 2^{-k}) val(z)`; and if `Σ val(z_j) ≤ N`, `N ≥ 4`, it uses `O((k + log log N) log r)` working bits.
**Formalization Note.** `Sum_k` is `sumK`, the merge of the proof. The space clause is a `reading`: for each `(k, r, N)`, one finite-state `Evaluator` with a bounded number of state bits, one update per counter, whose output is `sumK k` on every admissible input. `O(·)` is one absolute `K` before `k, r, N`, and `log = log₂`. `x_j` are real numbers. -/
theorem lemma_7_5 : ∃ K : ℝ, ∀ k : ℕ, 1 ≤ k →
(∀ zs : List (ℕ × ℕ), 2 ≤ zs.length → (∀ z ∈ zs, IsCounter k z) →
IsCounter k (sumK k zs) ∧
val (sumK k zs) ≤ (zs.map val).sum ∧
((zs.map val).sum : ℝ) ≤
Real.exp ((Nat.clog 2 zs.length : ℝ) * (2 : ℝ)⁻¹ ^ k) * (val (sumK k zs) : ℝ) ∧
∀ (xs : List ℝ) (θ : ℝ),
List.Forall₂ (fun z x => (val z : ℝ) ≤ x ∧ x ≤ Real.exp θ * (val z : ℝ)) zs xs →
(val (sumK k zs) : ℝ) ≤ xs.sum ∧
xs.sum ≤ Real.exp (θ + (Nat.clog 2 zs.length : ℝ) * (2 : ℝ)⁻¹ ^ k) *
(val (sumK k zs) : ℝ)) ∧
∀ r N : ℕ, 2 ≤ r → 4 ≤ N →
∃ ev : Evaluator Unit (ℕ × ℕ) (ℕ × ℕ),
(ev.bits : ℝ) ≤ K * ((k : ℝ) + Real.logb 2 (Real.logb 2 N)) * Real.logb 2 r ∧
∀ zs : List (ℕ × ℕ), zs.length = r → (∀ z ∈ zs, IsCounter k z) →
(zs.map val).sum ≤ N → ev.run () zs = sumK k zs := by sorry
end ExactPatternStream
Source
Gawrychowski, Janczewski, Jin, Nelson, An Improved Streaming Algorithm for Exact Pattern Matching (preprint, STOC 2027 submission, sha256 351218cb…), Lemma 7.5, p.20 (PDF 21)
Human review
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.