Uploaded by Dipanshu Choudhary

quiz2-final

advertisement
IITM-CS2200-2022 : Languages, Machines and Computation
Mar 26, 2022, 10am-11:30am
Quiz # 2
Max Marks : 25
Answer all questions. You can assume the theorems and proofs that we have done in class. Unless the question
specifically mentions, you do not need to write fully formal proofs. However, the idea of the construction/correctness
should be indicated in words.
1. (5 marks) Some statements about regular and context-free languages are given below along with one-line arguments for them. Comment on two aspects (1) whether the statement itself is true of false (2) the argument is
correct or incorrect. If argument is incorrect or statement itself is incorrect, point it out and give your supporting
arguments in 2-3 lines. The argument should convey the idea why you chose that answer.
(a) (1 mark) If h is a homomorphism from Σ∗ → Γ∗ , and A ⊆ Σ∗ is not regular, then h(A) cannot be regular
because Myhill-Nerode classes remain the same under homomorphisms.
(b) (1 mark) If a language A is finite, then A is necessarily a CFL, because every finite language is right-linear.
(c) (1 mark) A right-linear grammar always has an equivalent unambiguous grammar because a right-linear
grammar can never be ambiguous.
(d) (1 mark) If L is a CFL, L∗ is also a CFL because to get a grammar for L∗ , you can add a production S → SS
to the grammar for L, where S is the start symbol.
(e) (1 mark) The language A = {an b2n cn | n ≥ 0} is a CFL because both B = {an bn | n ≥ 0} and C = {bn cn |
n ≥ 0} are context-free, A = BC, and concatenation of two CFLs is always a CFL.
2. (5 marks) Consider the automaton M shown on the right side (q1 is the start state and q3 is the final state.
(a) (3 marks) Minimize the automaton using the marking
algorithm and write down the shortest string discovered
by your algorithm distinguishing the non-collapsable
states in the automaton. Draw the final automaton.
(b) (2 marks) Write down one example string each in each
of the equivalence classes of the coarsest Myhill-Nerode
relation on Σ∗ with respect to L(M ).
2
3. (4 marks) State the pumping lemma for CFLs. Prove that L = {an : n ≥ 0} is not a CFL using the lemma. The
structured way in which you write down the argument carries marks.
4. (6 marks) Let Σ = {0, 1}. Let x̄ denote the Boolean complement of x; that is, the string obtained from x by
changing all 0s to 1 and all 1s to 0s. Let xr denote the reverse of x; that is, the string x written backwards.
Consider the set
A = {x | xr = x̄}
(a) (3 marks) Write down a CFG generating this set. Give a formal proof that your grammar generates A.
(b) (3 marks) Convert your grammar from part (a) to Chomsky normal form to give a grammar for A \ {}.
Show the intermediate grammar fully after each step.
5. (5 marks) Consider the following language: L = {x ∈ {0, 1}∗ | x does not begin with a 0 }
(a) (2 marks) Construct a DFA accepting L having smallest number of states. Argue why your automaton has
the smallest number of states accepting this language.
(b) (3 marks) Prove that any DFA accepting the above language, no matter how many states it has, must necessarily have atleast two final states. (Your argument should be formal. It should not be just informal
arguments like “automaton should keep track of this information” etc.).
Download