This practical is based on the related lectures: Lecture 3: Context-Free Languages and Lecture 4: Pushdown Automata

Exercise 1

Given the following grammar

$$ \begin{array}{rcl} S & \rightarrow & ABA \;|\; BAB \\ A & \rightarrow & A\mathtt{a} \;|\;\mathtt{a}A\;|\;\epsilon \\ B & \rightarrow & \mathtt{b}B \;|\;B\mathtt{b} \;|\;\mathtt{b} \end{array} $$

Exercise 2

Propose grammars for the following languages:

Exercise 3

Provide a graphical representation of pushdown automata that recognise the following languages:

Exercise 4

Given the following pushdown automaton

PDA for Exercise 4

PDA for Exercise 4

provide a trace for the acceptance/rejection of the strings below. Your trace should consist of (i) the input tape and head position; (ii) the stack; (iii) the state of the automaton. Your trace MUST establish whether the string is accepted or rejected.