Block-Structured Witnesses for Pumping-Lemma Arguments #
A BlockWitness symbols p is the string s₀ᵖ s₁ᵖ ⋯ sₙ₋₁ᵖ formed by
concatenating one block of length p per symbol in symbols. Such witnesses
are the standard test strings for non-context-freeness arguments via the
CFL pumping lemma.
Three downstream consumers in Linglib.Core.Computability.NonContextFree
share this substrate: anbncndn, anbnc, and ambncmdn.
API #
Structure and counting:
BlockWitness symbols p— the witness construction.length_eq,length_take— size arithmetic.split_at— clean decomposition at any block boundary.filter_count— counts of in-alphabet symbols (each =p, byNodup).mem_iff— membership characterization.
Position bridge and adjacency:
getElem?_eq— the foundational position-to-symbol bridge:(BlockWitness symbols p)[i]? = symbols[i / p]?.not_both_in_vxy— the adjacency lemma: in any decompositionBlockWitness symbols p = u ++ vxy ++ zwith|vxy| ≤ p, two symbols at block-index distance≥ 2cannot both appear invxy. Used by every per-alphabetnot_X_and_Y_in_vxyconsumer inNonContextFree.leanas a one-line invocation with(by decide)discharging theNodupand index-distance hypotheses.
A block-structured witness: concatenates one block of length p per
symbol in symbols.
Equations
- BlockWitness symbols p = List.flatMap (fun (s : α) => List.replicate p s) symbols
Instances For
The witness splits cleanly at any block boundary.
Filter count: each in-alphabet symbol contributes exactly p; absent
symbols contribute 0. Requires symbols.Nodup so blocks don't merge.
A symbol appears in BlockWitness symbols p iff it's in symbols
(and p ≥ 1).
Position bridge. The character at position i in BlockWitness symbols p
is symbols[i / p]: the symbol whose block contains position i. Stated
with [?] (optional indexing) so the equation holds for all i —
out-of-range positions yield none on both sides.
This is the foundational position-vs-symbol bridge that makes
locality arguments trivial: any structural fact about which symbols
can appear at which positions reduces to integer division on the
block-length p.
Adjacency lemma. Two symbols at block-index distance ≥ 2 cannot
both appear in any vxy of length ≤ p arising from a decomposition
BlockWitness symbols p = u ++ vxy ++ z.
Proof: each occurrence of s (resp. t) in vxy corresponds to a
position in [|u|, |u| + |vxy|) whose block index (pos / p) equals
i (resp. j) by Nodup. The two positions differ by less than
|vxy| ≤ p, so their block indices differ by at most 1 — contradicting
j ≥ i + 2.