Lemma 4.7 — equal fragments after active triggers pad identically
ProvedExactPatternStream.lemma_4_7fingerprintingp2o-gran-per-chapterp2o-plan-paperp2o-v1pattern-matchingrandomized-algorithmsstreaming-algorithmsstring-algorithms
For let be annotated strings, , , fresh, and let with position maps . Suppose , that , and that with for both . Then, with , ,
The padding of a fragment that starts just after an active trigger depends only on the fragment, which is what keeps pattern and text parses synchronized.
Differences from the source: none.
Preamble
import Mathlib import Definitions.Def_ExactPatternStream_Strings import Definitions.Def_ExactPatternStream_Pad
Formal statement
namespace ExactPatternStream
/-- Gawrychowski, Janczewski, Jin, Nelson, *An Improved Streaming Algorithm for Exact Pattern Matching* (preprint, STOC 2027 submission, sha256 351218cb…), Lemma 4.7, p.8 (PDF 9).
Equal annotated fragments, each beginning immediately after an active trigger, are padded identically.
**Formalization Note.** `u ≠ v`, `c > 0`, `# ∉ Σ` and `|A_r| = |S_r| + 1` are the conditions of the setup of Definitions 4.1 and 4.3. `(S₁, A₁)[x₁ . . y₁) = (S₂, A₂)[x₂ . . y₂)` is the two slice equalities, and `A'[x' . . y']` is closed, so it includes position `y'`. -/
theorem lemma_4_7 {α : Type*} [DecidableEq α] (S₁ S₂ : List α) (A₁ A₂ : List Bool) (u v hash : α) (c : ℕ)
(huv : u ≠ v) (hc : 0 < c) (hS₁ : hash ∉ S₁) (hS₂ : hash ∉ S₂)
(hA₁ : A₁.length = S₁.length + 1) (hA₂ : A₂.length = S₂.length + 1)
(x₁ y₁ x₂ y₂ : ℕ) (hx₁ : c + 1 ≤ x₁) (hxy₁ : x₁ ≤ y₁) (hy₁ : y₁ ≤ S₁.length)
(hx₂ : c + 1 ≤ x₂) (hxy₂ : x₂ ≤ y₂) (hy₂ : y₂ ≤ S₂.length)
(hS : slice S₁ x₁ y₁ = slice S₂ x₂ y₂) (hA : slice A₁ x₁ y₁ = slice A₂ x₂ y₂)
(ht₁ : slice S₁ (x₁ - c - 1) x₁ = List.replicate c u ++ [v])
(ht₂ : slice S₂ (x₂ - c - 1) x₂ = List.replicate c u ++ [v])
(ha₁ : A₁.getD (x₁ - c - 1) false = true) (ha₂ : A₂.getD (x₂ - c - 1) false = true) :
let r₁ := pad S₁ A₁ u c v hash
let r₂ := pad S₂ A₂ u c v hash
let ρ₁ := padRho S₁ A₁ u c v
let ρ₂ := padRho S₂ A₂ u c v
slice r₁.1 (ρ₁ x₁) (ρ₁ y₁) = slice r₂.1 (ρ₂ x₂) (ρ₂ y₂) ∧
slice r₁.2 (ρ₁ x₁) (ρ₁ y₁ + 1) = slice r₂.2 (ρ₂ x₂) (ρ₂ y₂ + 1) := by sorry
end ExactPatternStream
Source
Gawrychowski, Janczewski, Jin, Nelson, An Improved Streaming Algorithm for Exact Pattern Matching (preprint, STOC 2027 submission, sha256 351218cb…), Lemma 4.7, p.8 (PDF 9)
Human review
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.