Intersection of Context-Free and Regular Languages #
This file proves that the intersection of a context-free language with a regular language is context-free. This is a classic result in formal language theory, proved via the product construction of a CFG and a DFA.
Proof idea: thread DFA states through the nonterminals of the context-free grammar. A product nonterminal records both the original grammar symbol and the DFA state change that the substring generated by that symbol must realize, so a complete derivation exists exactly when the CFG derives the word and the DFA accepts it.
Main declarations #
CF_of_CF_inter_regular: the main theoremproductGrammar: the product CFG×DFA grammar construction
CF_derivesIn g n w₁ w₂ means g transforms w₁ to w₂ in exactly n steps.
Uses tail convention (matching ReflTransGen).
- refl {T : Type} {g : CF_grammar T} (w : List (symbol T g.nt)) : CF_derivesIn g 0 w w
- tail {T : Type} {g : CF_grammar T} {n : ℕ} {w₁ w₂ w₃ : List (symbol T g.nt)} : CF_derivesIn g n w₁ w₂ → CF_transforms g w₂ w₃ → CF_derivesIn g (n + 1) w₁ w₃
Instances For
The product grammar of a CFG g and a DFA M.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The class of context-free languages is closed under intersection with regular languages.