问题
Is the union of a collection of context-free languages always context-free ? Justify your answer .....
I know that the answer is yes, but how can I prove it ?
回答1:
To show that the finite union of context-free languages is context-free you just have to build a context-free grammar for the union language, exactly as you would do to prove that the union of two context-free languages is context-free.
If G1,...,GN are the context-free grammars for the N context-free languages you have, rename all the symbols in the each grammar (add a subscript just to avoid symbol name clashes) and then make a new grammar G with all the productions from the N grammars, plus the production:
S -> S1 | S2 | ... | SN
This grammar generates the union language, and it is context-free.
来源:https://stackoverflow.com/questions/10377438/union-in-context-free-languages