Theory Context_Free_Grammar
section "Context-Free Grammars"
theory Context_Free_Grammar
imports "HOL-Library.Infinite_Typeclass"
begin
definition fresh :: "('n::infinite) set ⇒ 'n" where
"fresh A = (SOME x. x ∉ A)"
lemma fresh_finite: "finite A ⟹ fresh A ∉ A"
unfolding fresh_def by (metis arb_element someI)
declare relpowp.simps(2)[simp del]
lemma bex_pair_conv: "(∃(x,y) ∈ R. P x y) ⟷ (∃x y. (x,y) ∈ R ∧ P x y)"
by auto
lemma in_image_map_prod: "fgp ∈ map_prod f g ` R ⟷ (∃(x,y)∈R. fgp = (f x,g y))"
by auto
subsection "Symbols and Context-Free Grammars"
text ‹Most of the theory is based on arbitrary sets of productions.
Finiteness of the set of productions is only required where necessary.
Finiteness of the type of terminal symbols is only required where necessary.
Whenever fresh nonterminals need to be invented, the type of nonterminals is assumed to be infinite.›