Let $G$ be a grammar for some context-free language $L$, and let $F$ be a finite set of strings. Explain how to modify $G$ to create a context-free grammar for $L\cup F$.
Can someone give me an example to this problem?
Let $G$ be a grammar for some context-free language $L$, and let $F$ be a finite set of strings. Explain how to modify $G$ to create a context-free grammar for $L\cup F$.
Can someone give me an example to this problem?
Let $S$ be the start symbol of your grammar and let $T$ be a new symbol not used in the grammar. If $F = \{u_1, \ldots, u_n\}$, just add the rules $S \to T$ and $T \to u_1 + \dots+ u_n$.