CS304                                                       Assignment 1
Formal Languages and                                               6 August 2020
        Automata Theory
                                           Assignment 1
                                             ( 30 marks)
This assignment has 10% weight. You can do it together with your previous group partner (one
uploads, only) or by yourself. Identical solutions will lead to disqualification of the submitters
for all the three assignments. Submit your solution by Sunday 9th August, midnight.
Exercise 1     Grammar Design (6 marks)
Consider the language L = {ai bj ck | i, j, k ≥ 0, i = j or j = k}.
  (a) Give a context-free grammar generating L.
  (b) Is there a word in G which has two different parse trees? Justify your answer.
  (c) Prove that L is not regular. Use any proof technique you find appropiate.
Exercise 2    Grammar Transformation (2 marks)
Consider the grammar G via its rules:
 S → aAD
 A → aB | bAB
 B → b
 D → d
Transform G into an equivalent grammar in Chomsky normal form.
Exercise 3    Pumping Lemma (6 marks)
Consider the L = {wwR w | w ∈ {a, b}∗ }.
(1)    Which of the following words are suitable to prove that L is not context-free using the
Pumping Lemma.
  (a) w1 = aN
  (b) w2 = aN bba2N b
  (c) w3 = (ab)N (ba)N (ab)N
 (d) w4 = aN b2N a2N bN
where N is the constant of the Pumping Lemma for the given language.
(2)   For the words you diagnosed not to be suitable, explain why.
Exercise 4    Grammars and Automata (6 marks)
Let A = (Q, Σ, δ, q0 , F) be an DFA.
  (a) Give a context-free grammar G such that L(A) = L(G). Give the general method not just
      one example.
  (b) Prove that L(A) ⊆ L(G) by a suitable induction. State clearly the Induction Hypothesis
      and explain your proof steps.
Exercise 5    Pushdown Automata (4 marks)
Consider again the language L = {ai bj ck | i, j, k ≥ 0, i = j or j = k}.
  (a) Give a PDA which accepts the language with final state acceptance condition.
  (b) Give a PDA which accepts the language with empty stack acceptance condition.
Exercise 6    Some Language (6 marks)
Consider the language L which contains all words of the form wan where w ∈ {−1, 0, 1}∗ and
n is the absolute value of the sum of the letters interpreted as numbers of w. For example,
110-1a, 11-1011-11aaa and -1-1aa are in L.
  (a) Decide whether L is regular, context free or neither or these.
  (b) If possible give a PDA accepting L, otherwise prove that L is not context free.