Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Summer Examination Period 2021 — May/June — Semester B

ECS421U   Automata and Formal Languages

Question 1

This question is about nite-state automata (FSAs), and context-free grammars (CFGs). You are given the following automaton A over the alphabet Σ = {a, b, c}:

a, b

a

 

(a)  Give a formal denition (i.e. as a 5-tuple) of the above automaton A.

[5 marks]

(b)  Give two words contained in the language accepted by the automaton A, and two words not contained in the language accepted by the automaton A.

[2 marks]

(c)  Explain what makes the automaton A non-deterministic.

[2 marks]

(d)  Give, as transition graph, a deterministic FSA that accepts the same language as A. Justify your answer, for example by following the subset construction.

[8 marks]

(e)  Give, as transition graph, the minimal deterministic FSA accepting the same language as A.

Justify your answer, for example by building a marking table of necessarily distinct states. Make sure you show why each marked entry in the table gets marked.

[8 marks]

Question 2

This question is about regular expressions (REs) and nite-state automata (FSAs).

Notation: in the REs below, the Kleene star has higher precedence than sequencing; and sequencing has higher precedence than +. E.g. 10* 1 + 11* 1 = (1(0* )1) + (1(1* )1).

(a)  Consider the regular expression r:

b (ab + ba)* b

(i)  Which of the following words (by e we denote the empty word) belong to the language defined by r, and which do not?

e, bb, bab, baba, babbab

Briey justify your answer, for example by explaining how the regular expression will accept (i.e. match) the words that belong to its language, and how it will not accept those that do not belong in it.

[5 marks]

(ii)  Give, as a transition graph, an FSA (possibly with e-transitions) recognising the same language as r .

Note: You should not use transitions with composite labels, e.g. of the form q1   q2 .

[5 marks]

(b)  Syntactically different regular expressions may represent the same language. Consider regular expressions over Σ = {a, b}. Which of the following equations hold?

1.   a + b = b + a

2.   (a + b)*  = a* + b*

3.   (a + b + ba)*  = (a + b + ab)*

Briey justify your answers.                                                                                     [6 marks]

(c)  Consider the following languages over the alphabet {a, b, c}:

1.  The language of all words which contain at least one a, an arbitrary number of b’s and no c’s.

2.  The language of all words which start with a and have even length.

For each of the above languages, give an FSA or a regular expression that defines them.

You do not need to justify your answers.

[5 marks]

(d)  Let L be the language of all words over {a, b, c} which start with a and have even length. Give an FSA or a regular expression defining the complement language of L, i.e. the language of all words over {a, b, c} which do not belong in L.

Brieyjustify your answer, i.e. explain why your FSA/RE accepts the complement language.

[4 marks]

Question 3

This question is about pushdown automata (PDAs) and context-free grammars (CFGs). (a)  You are given the following PDA A with Σ = {a, b, c} and Σst  = {$, 0}:

pop($)

 

(i)  Give three words accepted by the automaton A, and three words that are not accepted by A. Two of the accepted ones should contain at least one a.

[6 marks]

(ii)  For two of the three accepted words, give an accepting run.

[6 marks]

(iii)  Give a context-free grammar recognising the same language as the PDA A.

[3 marks]

(b)  Consider the following context-free grammar G over the alphabet Σ = {a, b, c}, where S is the start variable:

S  →  aXSb | ε | bX

X  →  XbX | c

(i)  Using the rules of the grammar G, give a derivation for the word bc.

[2 marks]

(ii)  Give a PDA recognising the same language as the grammar G.

Note: You can use the general method we saw in the lectures, or nd the PDA by in- spection. Moreover, you can use composite-push transitions of the form push(x1 · · · xn ),

for n > 1.                                                                                                           [6 marks]

(iii)  Using the PDA you constructed in (ii) above, give an accepting run for the word bc.

[2 marks]

Question 4

This question is about context-free grammars and parsing, and Turing machines (TM’s). Consider the following context-free grammar G over the alphabet Σ = {a, b}:

S  →  aSb | XbX

X  →  cX | c | ε

where S is the start variable.

(a)  Using the rules of the grammar G, construct parse trees for the words acbb and bccc.

[6 marks]

(b)  Give 2 words (from Σ* ) that are not in the language accepted by the grammar G.

Justify your answer, explaining why are the words you give not accepted.

[3 marks]

(c)  Using any of the grammar transformation techniques we saw in this module, construct a CNF grammar that generates the same language as G.

Make sure you include in your answer all individual steps that you followed.

[10 marks]

(d)  Construct a Turing machine accepting the following language over Σ = {a, b, c}: L = { ai+1 bi c2i  | i ≥ 0 }

Justify your answer, explaining how the TM you constructed will accept words in the language L.

Hint: think about the TM accepting the language { 0i 1i 2i   | i ≥ 0 } and how can it be changed to accept the language above.

Notation: recall above that e.g. we write c2i for the word consisting of 2i-many cs.

[6 marks]