This practical is based on the related lecture: Lecture 5: Context-Sensitive Grammars, LBAs and Chomsky’s Hierarchy

Question 1

Given the following context-sensitive grammar (variables $S, U$; terminals ☺, ☹, ☻):

Provide a derivation and a parse tree for ☺☺☺☹☹☹☻☻☻ if these exist. If they don't exist, explain why.

Question 2

Provide a context-sensitive grammar (CSG) for the language $L=\{\mathtt{a}^n\mathtt{b}^{2n}\mathtt{c}^n \mid n\in\mathbb{N}\}$. Show derivations for strings when $n=0, 1,$ and $2$.

Question 3

Given the following LBA, where a transition $(q',a',d) \in \delta(q,a)$ is represented as an arrow from $q$ to $q'$ labelled $a, a'/d$:

LBA for Question 3

LBA for Question 3

Provide a computation/run for the following inputs:

  1. $\blacktriangleright\mathtt{111}\blacktriangleleft$
  2. $\blacktriangleright\mathtt{1101}\blacktriangleleft$

Question 4

Define a linear-bounded automaton to recognise $\{\mathtt{0}^n\mathtt{1}^n\mathtt{2}^n \mid n\in\mathbb{N}\}$.

Question 5

Describe how an NFA $N=(Q,\Sigma,\delta,q_0,F)$ can be converted to an equivalent LBA $M=(Q',\Sigma',\Gamma',\delta',q'_0,F')$.