Union in context-free languages

我的未来我决定 提交于 2019-12-13 08:35:40

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!