Decidability and Computability of Membership #
This file proves that membership is decidable—and indeed computable—for context-free languages (represented by context-free grammars).
The proof proceeds via the CYK algorithm on Chomsky-normal-form grammars.
Main results #
cf_membership_computable– membership in a context-free language is a computable predicate (ComputablePred), which in particular implies decidability.
Part 1: Context-Free Languages – CNF Decidability #
CYK-style predicate: can nonterminal n derive word w in CNF grammar g?
Quantifies over rules (a Finset) instead of nonterminals, so does NOT require
Fintype g.NT.
Equations
Instances For
Bool-valued CYK decision function. Takes an explicit list of rules so that the
function is genuinely computable (not noncomputable).
Equations
- One or more equations did not get rendered due to their size.
- ChomskyNormalFormGrammar.cykDecideAux rulesList n [] = false
Instances For
canDerive is equivalent to Derives (derivation in the CNF grammar).
Bitvector operations #
Primrec proofs for bitvector operations #
Fold over fixed lists is Primrec #
Folding over a fixed list with a Primrec step function is Primrec.
CYK Table Definitions (Bitvector-based) #
Bitvector lookup for terminal rules: given terminal t, compute the bitvector
of nonterminals with leaf rule nt → t.
Equations
Instances For
Build the CYK table bottom-up.
The result is a flat List ℕ where entry at index l * n + i
(with n = w.length) is the bitvector of nonterminals that derive
the substring w[i .. i+l] (length l+1 starting at position i).
extraRows is the number of rows beyond the base row.
Equations
- One or more equations did not get rendered due to their size.
- cykBuildTable leafData nodeData w 0 = List.map (cykLeafBV leafData) w
Instances For
CYK Bitvector is Primitive Recursive #
The fold over all rules (fixed nodeData) is Primrec₂.
The full membership check is Primrec.
CYK Bitvector Correctness #
Base case of CYK correctness: single characters.
cykDecideAux on a word of length ≥ 2 checks split points and node rules.
Step case of CYK correctness: longer substrings.
Requires h_node_range to ensure all nodeData entries are in range of enc.
Key correctness lemma: CYK bitvector table entries correspond to cykDecideAux.
Proved by strong induction on l.
Main theorem: CF membership is ComputablePred #
Membership in a context-free language is a computable predicate.
Membership is uniformly computable for the context-free languages: encoded
context-free grammars are an adequate, effective presentation
(contextFreeLanguageOf_characterizes) with uniformly decidable membership
(ComputableMembership).