0

Is a suitable way to prove that any given CFG generates (or not) any given language to draw its total language tree?

What if the tree is infinite? What would then be a better way to prove that a given CFG generates a given language?

Älskar
  • 264
  • 3
  • 10

2 Answers2

1

Suppose that we have a context-free grammar $G$ and a set of words $S$, and we would like to prove that the language $L(G)$ generated by $G$ is precisely the set $S$. The most direct way of doing this is to prove $L(G) \subseteq S$ and $S \subseteq L(G)$, which amounts to showing:

  1. For every $x \in L(G)$ we have $x \in S$.
  2. For every $y \in S$ we have $y \in L(G)$.

How this is done depends on how the set $S$ is given, so there is no further, more specific advice that I can offer, except that drawing trees is not really going to result in a proof.

Andrej Bauer
  • 31,657
  • 1
  • 75
  • 121
0

If your language $L$ is, as you state in the comment, given as a regular expression, you can prove that the grammar $G$ generates it in two steps.

  1. Prove that $G$ is regular
  2. Show that the two automatons (from $G$ and from the expression for $L$) recognizing the language are the same.
adrianN
  • 5,991
  • 19
  • 27