You are on page 1of 2

CSC701

Assignment 2
Due date : 19/2/2022

1. Use Pumping Lemma to prove that {0n12n | n >= 1 } is not regular

2. Consider the following grammar G that generates expressions involving the binary
operators , , , :

E  E  E | E  E | EE | E E | (E) | x

a. Show that the following grammar G is ambiguous.


b. Suppose the evaluation order of an expression is defined by the following rules:
 An expression inside parentheses is evaluated first
 The precedence of operators, from highes to lowest, is:
 
(where equality indicates the operators have the same precedence).
 Operations with the same precedence are evaluated from right to left..
Convert G into an equivalent grammar that enforces these evaluation rules. Is the
new grammar ambiguous? Briefly argue why or why not.

3. Suppose the PDA P=({q,p},{0,1},{# ,X},δ,q,#,{p})

Has the following transition function:


δ(q,0,#)={(q,X#)} δ(q,0,X)={(q,XX)}
δ(q,1,#)={(q,#)} δ(q,λ,X)={(p,λ)}
δ(P,λ,X)={(p,λ)} δ(P,1,X)={(P,XX)}
δ(P,1,#)={(P,λ)}

Starting from initial ID (q, w, #), show all the reachable ID’s when the input w is :
a) 0011
b) 010

4. Construct npda that will accept the language generated by the grammar
G  ({S , A},{a, b}, S , P) with productions:
S → AA | a
A → SA | b

5. Convert the following grammar to:


a. Chomsky Normal Form
b. Greibach Normal Form

S → AaA | CA | BaB
A → aaBa | CDA | aa | DC
B → bB | bAB | bb | aS
C → Ca | bC | D
D → bD | b
6. What language is accepted by the machine
M  ({q0 , q1, q2 , q3},{a, b},{a, b, }, , q0 , ,{q3}) with

(q0 , a)  (q1, a, R),


(q0 , b)  (q2 , b, R ),
(q2 , b)  (q1 , b, R),
(q1 , )  (q3 , , R),
(q2 , b)  (q2 , b, R ),
(q2 , a)  (q3 , a, R).

7. Construct Turing machines that will accept the following languages on {a,b}:

a. L  L(abba *b * a)

b. L  {a nbn a nbn : n  0}

8 Design a Turing machine by providing the algorithm and transition diagram for
the following problem specification.

Input : n 1's, 0, m 1's, 0, more than n*m b's


Output : replace n*m b's with 1's
(It does not matter what happens to other 1's)

Example Input : 1101110bbbbbbb (2x3=6)


Output : ??0???0111111b

Example Input : 110110bbbbb (2x2=4)


Output : ??0??01111b

b) Show the ID for input 1101110

9 L = { ww | w in Σ* } is not a CFL. L is recognized by a Turing machine. What essential


feature does a Turing machine have that a NPDA did not have to be able to
recognize L ?

You might also like