File CoMoLang.CFG
Context-free grammars (CFG) are grammars, where the left side of a rule X -> Y only consists out of exact one variable.
Class CFG (V Sigma : Set) :=
{
CFG_Grammar :> Grammar V Sigma;
rule_left_side :
∀ t1 t2,
@rule V Sigma CFG_Grammar t1 t2 →
∃ (v : V),
t1 = (inl v) :: nil
}.
{
CFG_Grammar :> Grammar V Sigma;
rule_left_side :
∀ t1 t2,
@rule V Sigma CFG_Grammar t1 t2 →
∃ (v : V),
t1 = (inl v) :: nil
}.
A language L is called context-free (cf.), iff there is a CFG, which produces L.
Definition is_cf {Sigma} `(L : Language Sigma) :=
∃ (V : Set) `(G : CFG V Sigma),
grammar_produces (@CFG_Grammar V Sigma G) L.
Print is_cf.
∃ (V : Set) `(G : CFG V Sigma),
grammar_produces (@CFG_Grammar V Sigma G) L.
Print is_cf.
A trivial helper fact.