2. Design a finite automaton for recognizing binary sequences that
have even number of a's or even number of bs. Assume that the input
strings contain only symbols a and b. The easiest is to have 4
states:
- a final state ee in which we have even number of
a's and even number of b's,
- a final state eo, in which we have
even number of a's and odd number of b's, and
- similarly
defined states oe (odd-even, final) and oo (odd-odd, not
final).
You just need to describe transitions between these
states, and which states are final. Show, step-by-step, how your
automaton will accept the string aba. Show how the general
algorithm will produce a context-free grammar that generates all
the words accepted by this automaton -- and only words generated by
this automaton. On the example of a word aba accepted by this
automaton, show how the tracing of acceptance of this word by the
finite automaton can be translated into a generation of this same
word by your context-free grammar.
3. Use the general algorithm to transform the grammar from Problem
1 into Chomsky normal form.
4. Use the general algorithm to transform the following pushdown
automaton into a context-free grammar. This automaton has 4 states:
- the starting state s,
- the reading state r,
- the
checking state c, and
- the final state f.
The transitions
are as follows:
- From s to r, the transition is:
- From r to r, the
transitions are:
- From r to c, we have a jump ε,
ε → ε.
- From c to c, the transitions are:
- From c to f, the only transition is:
Show, step-by-step, how the resulting
grammar will generate the sequence
0101.
5. Show, step by step, how the stack-based algorithm will transform
the expression 5 − (3 − 7) into a postfix expression,
and then how a second stack-based algorithm will compute the value
of this postfix expression.
6. For the grammar from Problem 1, show how the word dccd can be
represented as uvxyz in accordance with the pumping lemma for
context-free grammars. Show that the corresponding word uvvxyyz
will be generated by this grammar.