Upload
thangamari
View
154
Download
12
Embed Size (px)
Citation preview
1
Roll No: ________
ATMIYA INSTITUTE OF TECHNOLOGY & SCIENCE MODEL QUESTION PAPER I
B.E. 6th Sem (CE)
SUB: Theory of Computation Total Marks: 30 Time Allowed: 1:30 Hr
Q.1 Do as Directed. (a) True or false? Justify your answer.
1) Pumping lemma show that language is regular. Answer: False We cannot use pumping lemma to prove a language is regular. This is because the set of regular languages is a proper subset of the set of pumping languages, i.e. there are languages which satisfy the pumping condition but are nonregular. So even if we show that a language satisfies the pumping condition it does not imply that the language is regular. But since all regular languages satisfy the pumping condition, we can show that a language is not regular by showing that it does not satisfy the pumping condition.
2) The regular language is closed under Union and complement. Answer: True If L 1 and L2 are regular language then L1∪L2 also regular ( by recursive definition of regular language (step 4)). To find complement of RL, all accepting state becomes non-accepting state and non-accepting state becomes accepting states hence resultant complement language is also RL.
3) If L 1 is nonregular, L2 is nonregular then L1 ∩ L2 is nonregular Answer: False The intersection of a nonregular language and it’s complement is empty and empty language is regular Ex. L1 =PAL L2= Complement of PAL So L1 ∩ L2 = Φ and Φ is a regular language,
4) The transition function δ: Q x Σ � 2Q is a Partial Function. Answer: False A partial function from X to Y is a function ƒ: X' → Y, where X' is a subset of X. It generalizes the concept of a function by not forcing f to map every element of X to an element of Y (only some subset X' of X). But, in NFA it necessary that every element of domain must relates with at least one element of co-domain.
5) Φ*=Φ Answer: False Φ* = { Φ0, Φ1¸Φ2¸Φ3, …,Φ∞ } Here, Φ0 is a null string and remaining all elements are Φ ⇒ Φ*=∧
2
(b) Do as Following (Any Two)
1) Show that the relation “congruence modulo m” over the set of positive integers is an equivalence relation. Answer: Assume that N = Set of all positive integers and m = given positive integer. For x, y∈ N, x ≡ y (mod m) if and only if x – y is divisible by m, i.e.
x − y = km, for k ∈ z.
2) Write the regular expression for “All strings of 0’s and 1’s having even number of 0’s
and odd number of 1’s”.
3) Prove that following functions is a bijection from R to R and find f -1.
f (x) = (x 2 +1) / (x 2 + 4) Answer:
In order to prove that function is bijection, we have to prove that it is one to one and onto function:
Prove that function is one to one: Let x1 and x2 be two real number such that f(x1) = f(x2) ⇒ (x1
2 + 1)/ (x12 + 4) = (x2
2 + 1)/ (x22 + 4)
⇒ x12 x2
2 + 4x12 + x2
2 + 4 = x12 x2
2 + x12 + 4x2
2 + 4 ⇒ 3x1
2 = 3x22
⇒ x12 = x2
2
⇒ x1 = x2
Hence f is one to one function.
Prove that function is onLet y be a real number such that some x
(x 2 +1) / (x 2 + 4) = y (x 2 +1) = y(x 2 + x 2 +1 = yx 2 + 4y(1-y) x 2 = 4y-1 x= (4y-1)/(1-y)
now, put value of x into f(x) (x 2 +1) / (x 2 + 4) = (( (4y = (4y- = 3y/3 = y Hence, f is onto functionSo, f is bijection functionAnd f-1 (y) = (4y-1)/(1-y)
Q.2 Do a Following (a) Draw a DFA for following (Any two)
1. (1+01)*(0+^)
2. (00+11+(01+10)(00+11)*(01+10))*
3. All strings of 0’s and 1’s have length at most 5.
b) Prove that for any NFA M =<Q, <Q1, Σ, q1, A1, δ1> that also accepts L.
Prove that function is onto: Let y be a real number such that some x ∈ R, f(x) = y.
4) = y + 4) 4y )
now, put value of x into f(x)
= (( (4y-1)/(1-y) ) + 1) / (( (4y-1)/(1-y) ) + 4) -1 + 1-y) / (4y-1+4-4y)
3y/3
is onto function So, f is bijection function
(a) Draw a DFA for following (Any two)
(00+11+(01+10)(00+11)*(01+10))*
All strings of 0’s and 1’s have length at most 5.
Prove that for any NFA M =<Q, Σ, q0, A, δ> accepting language L ⊆ Σ*, there is a DFA M> that also accepts L.
3
*, there is a DFA M1=
4
Answer
5
6
7
Q.3 Do as directed. (Any two) (a) Use pumping lemma to show that following language is nonregular.(Any One)
1) The set of even-length strings over {0,1} with the two middle symbols are equal. Proof: We prove this by proof by contradiction. Suppose L is regular. Let n be an integer in theorem 5.2a. Let x = 0n001n where |x| ≥ n. Theorem say that x=uvw where some string u,v and w satisfying following condition
|uv| ≤ n (1) |v| > 0 (2) and for any m ≥ 0, uvmw ∈L (3)
let uv = 0k (for some k, all first occurrence of 0’s except middle 00). so, v =0j where j > 0 (by condition 2) let m=2 uvmw = uv2w = uvvw = 0n0j 001n = 0n+j 001n ∉ L because n+j ≠ n since j>0 so, our assumption is wrong. L is not regular language
2) L = {x ∈{0, 1}* | no prefix of x has more 0’s then 1’s} Proof: We prove this by proof by contradiction.
Suppose L is regular. Let n be an integer in theorem 5.2a. Let x = 0n1n where |x| ≥ n. Theorem say that x=uvw where some string u,v and w satisfying following condition
|uv| ≤ n (1) |v| > 0 (2) and for any m ≥ 0, uvmw ∈L (3)
let uv = 0k (for some k, all first occurrence of all 0’s). so, v =0j where j > 0 (by condition 2) let m=2 uvmw = uv2w = uvvw = 0n0j 1n = 0n+j 1n ∉ L because n+j ≠ n since j>0 so, our assumption is wrong. L is not regular language
b) Let M1 and M2 be the two FAs as given below.
Draw FA recognizing (L1 - L2) where L1 and L2 correspond to M1 and M2 respectively. Answer
8
9
10
11
c) Suppose M is the finite automata (Q, ∑, q0, A, δ ). Show that if for some state q, δ (q, a) = q, then δ*(q, x) = q for every x ∈ ∑*. Answer:
12
13