1

I am trying to understand how to write the language given the predicates of the context free grammar. As an example, I have the following grammar:

$S \to 0B \mid 1A$

$A \to 0 \mid 0S \mid 1AA$

$B \to 1 \mid 1S \mid 0BB$

What this says to me is that the first symbol can be either a 0 or 1, and the next could be 0 or 1 or 1 or 0, and you continue down the parse tree from there. How does one determine what the language of the grammar is? I having trouble putting the patterns of symbols into a language definition.

Raphael
  • 73,212
  • 30
  • 182
  • 400
mandib
  • 25
  • 4

1 Answers1

1

Structural induction would prove the following:

  • All words generated from $S$ have the same number of 0s and 1s.
  • All words generated from $A$ have an excess of one 0.
  • All words generated from $B$ have an excess of one 1.

Presumably the reverse is also true, but I'll leave such pondering for you.

Yuval Filmus
  • 280,205
  • 27
  • 317
  • 514