Theorem 8. Near-linear matching for every one-use expression
ProvedBackreferenceMatching.theorem_8Given a one-use expression and a word , one uniform word-RAM algorithm decides whole-word membership in time, including preprocessing, where . Different branches can read different variables. Every complete computation must use at most one read in total.
import Definitions.Def_BackreferenceMatching_Algorithms
namespace BackreferenceMatching
theorem theorem_8 (q : ℕ) :
∃ (p : Program) (a c : ℕ), 0 < c ∧
∀ (e : Expr q), BoundedUse 1 e → ∀ w : Word q,
DecidesWithin p a q (regexInput e w) (Matches e w)
(2 ^ (c * e.size^4) * (w.length + 1) * (logFactor w.length)^2) := by
sorry
end BackreferenceMatchingRead-back
What the Lean code literally says, in plain math · GPT-6
For every , there are a finite deterministic word-RAM program , a natural number , and a positive integer with the following property. Suppose is an expression with captures and variable reads over , and every complete successful derivation of from initially empty variable values makes at most one read in total across all variables. For every word over , decides whether some derivation from those initial values consumes exactly . It halts within instructions, where is the number of syntax nodes in , , and .
Variables have natural-number names. A capture first runs its body, then sets its variable to the whole word the body consumed, preserving the other values the body leaves. A read consumes the current value of its variable, leaves all values unchanged, and counts once even when that value is empty. Union chooses either branch. Concatenation and finite star iteration pass the resulting variable values forward and add the read counts. The empty-language expression has no derivation. The empty-word and letter expressions consume the empty word and the indicated letter, respectively, with zero reads. The read bound holds vacuously if there is no successful derivation. The target may be empty, including when .
The entire output is for a match and otherwise. For an input of entries, the machine uses bits per word, with initially zero writable cells and sequential and indexed input reads. Each executed instruction costs one, including a halt or an exhausted sequential read. An out-of-range program counter ends execution at no additional cost.
The input concatenates the prefix code of and the numeric letters of . The tags for the empty language, the empty word, a letter, union, concatenation, star, capture, and read are , respectively. A letter carries its numeric value. Each capture or read carries the zero-based index of its variable in the list of distinct names encountered in left-to-right preorder. Child expressions follow the tag and any associated index, in order.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.