Distinct factors of a straight-line grammar
ProvedPvsNP.grammar_factor_count_lecombinatoricscomplexity-theoryformal-verification
A straight-line grammar has g productions listed in dependency order. Each expansion has length at most one or is the concatenation of two earlier expansions. For k at least two, any set of distinct length-k contiguous factors of one expansion has cardinality at most g(k−1).
Preamble
import Mathlib set_option autoImplicit false
Formal statement
theorem PvsNP.grammar_factor_count_le {α : Type} [DecidableEq α] (g k : ℕ)
(expand : Fin g → List α) (leftChild rightChild : Fin g → Fin g)
(rules : ∀ i, (expand i).length ≤ 1 ∨
(leftChild i).val < i.val ∧ (rightChild i).val < i.val ∧
expand i = expand (leftChild i) ++ expand (rightChild i))
(root : Fin g) (factors : Finset (List α)) (nontrivial : 2 ≤ k)
(occurs : ∀ w ∈ factors, w.length = k ∧ w <:+: expand root) :
factors.card ≤ g * (k - 1) := by sorrySource
Rule-boundary counting, related to Kempa and Prezza, At the Roots of Dictionary Compression: String Attractors, STOC 2018.