We consider a grammar , where , and are a finite set of terminal symbols, a finite set of nonterminal symbols, a finite set of production rules, and the start symbol, respectively.
The following is a description on context-free grammar. Fill the blanks (1), (2), and (3).
A grammar is a context-free grammar when, for each production rule in , and . A language on is a context-free language when it is generated by a context-free grammar .
Prove that the class of context-free languages is closed under concatenation by constructing from the context-free grammars and generating and , respectively.
every generated string has a part of substrings (at left) in (derived from ), while the right part is in derived from , forming . Every string in can also be generated by by separating into 2 parts and finding the corresponding and rules from and .
every generated string either falls in by applying in the first step or falls in by ; every string in language can find the generation rules in or plus the or rule.
because in RHS, the number of a's and b's must be equal and that of b's and c's are also equal, so the intersection is by definition , and is not a CFL, if the class of CFLs are closed under complement, then for CFL, and are CFLs, and is a CFL, and thus
is a CFL (contradiction), hence under complement the class is not closed.
Since is a CFL with a context-free grammar of , an arbitrary , a rule set with every possible rule based on and and a start symbol , let be a CFL, assume under difference the class of CFLs is closed, then is a CFL.
However, is by definition not necessarily a CFL because in Q.5, complement cannot make the class closed (contradiction).
So under difference the class of CFLs is not closed.