EncodedCFG characterizes the context-free languages #
This file proves that the encoded-grammar encoding EncodedCFG denotes exactly the
context-free languages:
∀ L, L ∈ CF ↔ ∃ c : EncodedCFG T, contextFreeLanguageOf c = L
Soundness (every code denotes a context-free language): an EncodedCFG decodes —
by construction — to a CF_grammar (toCFGrammar), so its language is is_CF_via_cfg,
hence is_CF.
Completeness (every context-free language is encoded): a context-free language has a
CF_grammar presentation with finitely many nonterminals (exists_fintype_nt); we
reindex those nonterminals to Fin (n+1) and read the grammar off as an EncodedCFG.
Reindexing the nonterminals along an equivalence preserves the language
(cf_language_eq_of_rename), proved with the lifting machinery (lift_deri / sink_deri).
Renaming nonterminals preserves the language #
Renaming the nonterminals of a context-free grammar along an equivalence preserves
its language. Both directions go through the lifting machinery: lift_deri pushes a
derivation forward along e, and sink_deri pulls one back along e.symm.
The encoding #
Encode a context-free grammar whose nonterminals are indexed by Fin (k+1) (via the
equivalence e) as an EncodedCFG.
Equations
- One or more equations did not get rendered due to their size.
Instances For
toNT is the identity (up to Fin.val) on indices already in range.
Soundness and completeness #
Soundness: every code denotes a context-free language.
The language of the encoding of a finite-nonterminal grammar is the grammar's language.
Completeness: every context-free language is denoted by some code.
EncodedCFG characterizes the context-free languages (the library's class CF).