GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I Internal Examination 2017-18 B.Tech III Year VI Semester Sub: Theory of Computation (6CS3A) Time: 1 Hour 30 min. Max Marks: 40 Note: Attempt all three questions. Q. No. Q.1 (a) Question Marks CO Unit-1 Define automata. Explain finite automata with neat and labeled diagram. Also check acceptability of string 101101 for the given automata.. (06) CO363.1 1 1 The term "Automata" is derived from the Greek word "αὐτόματα" which means "self-acting". An automaton (Automata in plural) is an abstract self-propelled computing device which follows a predetermined sequence of operations automatically. An automaton with a finite number of states is called a Finite Automaton(FA) or Finite State Machine (FSM). Formal definition of a Finite Automaton An automaton can be represented by a 5-tuple (Q,, δ, q 0, F), where Q is a finite set of states. is a finite set of symbols, called the alphabet of the automaton. δ is the transition function. q 0 is the initial state from where any input is processed (q 0 Q). F is a set of final state/states of Q (F Q). An FA has three components: 1. input tape contains single string; 2. head reads input string one symbol at a time; and 3. Memory is in one of a finite number of states. String Acceptability: δ(q 0, 101101) δ(q 1, 01101) δ(q 3, 1101) δ(q 3, 101) δ(q 3, 01) δ(q 3, 1) q 3 Q.1 (b) As q 3 is the final state of the finite automata hence this string is accepted. Construct an NFA that accepts the set of strings defined over ={0,1} that (10)
starts with 1 and accepts the string of w mod 3=0 L={x * : x starts with 1 and x mod 3=0} Convert the NFA into equivalent DFA. Q.1 (a) OR Minimize the following finite automata. Also write procedure for minimization: (08) CO363.1 Step 1: State/Input 0 1 ->q0 q1 q3 q1 q0 q3
q2 q1 q4 q3 q5 q5 q4 q3 q3 *q5 q5 q5 Remove all un reachable states. Remove q2, q4 Step2: Separate into two sets Set 1 State/Input 0 1 ->q0 q1 q3 q1 q0 q3 q3 q5 q5 Set 2 State/Input 0 1 *q5 q5 q5 q3, q5 are indistinguishable states so we remove q3. Step 3:Combinning both sets State/Input 0 1 ->q0 q1 q5 q1 q0 q5 *q5 q5 q5 Transition Diagram 1 0 1 q 0 q 1 q 5 0,1 0 Q.1 (b) Construct a deterministic finite automata equivalent to the following NDFA. (08) Transition Table State/Input 0 1 2 ->q0 { q1, q4} q4 q3 q1 - q4 - q2 - - { q2, q3} *q3 - q4 -
q4 - - - Equivalent DFA Transition Table State/Input 0 1 2 ->q0 { q1, q4} q4 q3 *q3 - q4 - q4 - - - { q1, q4} - q4 - q0 1 q4 0 2 { q1,q4},q 1 q3 1 Q.2 (a) Unit-2 Define regular expressions and languages associated with regular expressions. Write the regular expression and finite automata (transition diagram) for following languages over alphabets = {a,b}. i) The set of strings that start with ab end with bb. ii) The set of strings that starts with a and ends with b and contain at least one sequence of aaa in that strings. Regular Expression Regular expressions can be thought of as the algebraic description of a regular language. Regular expression can be defined by the following rules: Every letter of the alphabet is a regular expression. Null string є and empty set Φ are regular expressions. If r1 and r2 are regular expressions, then (i) r1, r2 (ii) r1r2 ( concatenation of r1r2 ) (iii) r1 + r2 ( union of r1 and r2 ) (iv) r1*, r2* ( kleen closure of r1 and r2 ) are also regular expressions If a string can be derived from the rules 1, 2 and 3 then it is also a regular expression. Regular Language: Regular languages are languages that can be generated from one-element languages by applying certain standard operations a finite number of times. They are the languages that can be recognized by finite automata. These simple operations include concatenation, union and kleen closure. By the use of these operations regular languages can be represented by an explicit formula. (10) CO363.2
i) The set of strings that start with ab end with bb. ab(a+b)*bb a b b b q 0 q 1 q 2 q 3 q 4 a,b ii) The set of strings that starts with a and ends with b and contain at least one sequence of aaa in that strings. a(a+b)*aaa(a+b)*b a,b a a a q 0 q 1 q 2 q 3 a a,b q 3 b q 4 Q.2 (b) Use Arden s theorem to find regular expression for the following DFA. (6) q1= q1.0+ q3.0.(1) q2= q1.1+ q2.1+ q3.1 (2) q3= q2.0 (3) put value of (3) in (2) q2= q1.1+ q2.1+ q2.01 q2= q1.1+ q2.(1+ 01) Using Arden s Theorem q2= q1.1(1+ 01)*..(4)
Q.2 (a) put value of (3) in (1) q1= q1.0+ q2.00.(5) put value of (4) in (5) q1= q1.0+ q1.1(1+ 01)*.00+^ q1= q1(0+ 1(1+ 01)*.00)+^ using arden s theorem q1= (0+ 1(1+ 01)*.00)* Regular expression corresponding this DFA is (0+ 1(1+ 01)*.00)* OR Write the closure properties of regular languages. Explain pigeon hole principle. Prove that language L= {a n b n : n 0} is not regular using method of contradiction. Closure Properties of regular languages: Any set that represents the value of the Regular Expression is called a Regular Set. Properties of Regular Sets Property 1. The union of two regular set is regular. Let us take two regular expressions RE1 = a(aa)* and RE2 = (aa)* So, L1 = {a, aaa, aaaaa,...} (Strings of odd length excluding Null) and L2 ={ ε, aa, aaaa, aaaaaa,...} (Strings of even length including Null) L1 L2 = { ε, a, aa, aaa, aaaa, aaaaa, aaaaaa,...} (Strings of all possible lengths including Null) RE (L1 L2) = a* (which is a regular expression itself) Property 2. The intersection of two regular set is regular. Let us take two regular expressions RE1 = a(a*) and RE2 = (aa)* So, L1 = { a,aa, aaa, aaaa,...} (Strings of all possible lengths excluding Null) L2 = { ε, aa, aaaa, aaaaaa,...} (Strings of even length including Null) L1 L2 = { aa, aaaa, aaaaaa,...} (Strings of even length excluding Null) RE (L1 L2) = aa(aa)* which is a regular expression itself. Property 3. The complement of a regular set is regular. Let us take a regular expression RE = (aa)* So, L = {ε, aa, aaaa, aaaaaa,...} (Strings of even length including Null) Complement of L is all the strings that is not in L. So, L = {a, aaa, aaaaa,...} (Strings of odd length excluding Null) RE (L ) = a(aa)* which is a regular expression itself. Property 4. The difference of two regular set is regular. Let us take two regular expressions RE1 = a (a*) and RE2 = (aa)* So, L1 = {a, aa, aaa, aaaa,...} (Strings of all possible lengths excluding Null) L2 = { ε, aa, aaaa, aaaaaa,...} (Strings of even length including Null) L1 L2 = {a, aaa, aaaaa, aaaaaaa,...} (08) CO363.2
(Strings of all odd lengths excluding Null) RE (L1 L2) = a (aa)* which is a regular expression. Property 5. The reversal of a regular set is regular. We have to prove L R is also regular if L is a regular set. Let, L = {01, 10, 11, 10} RE (L) = 01 + 10 + 11 + 10 L R = {10, 01, 11, 01} RE (L R ) = 01 + 10 + 11 + 10 which is regular Property 6. The closure of a regular set is regular. If L = {a, aaa, aaaaa,...} (Strings of odd length excluding Null) i.e., RE (L) = a (aa)* L* = {a, aa, aaa, aaaa, aaaaa, } (Strings of all lengths excluding Null) RE (L*) = a (a)* Property 7. The concatenation of two regular sets is regular. Let RE1 = (0+1)*0 and RE2 = 01(0+1)* Here, L1 = {0, 00, 10, 000, 010,...} (Set of strings ending in 0) and L2 = {01, 010,011,...} (Set of strings beginning with 01) Then, L1 L2 = {001,0010,0011,0001,00010,00011,1001,10010,...} Set of strings containing 001 as a substring which can be represented by an RE (0 + 1)*001(0 + 1)* Pigeon Hole Principle: Theorem: If "n" number of pigeons or objects are to be placed in "k" number of pigeonholes or boxes; where k<n, then there must be at least one pigeonhole or box which has more than one object. Proof of Generalized Pigeonhole Principle In order to prove generalized pigeonhole principle, we shall use the method of induction. According to which we will assume the contradiction and prove it wrong. Let us suppose that total "nn" number of pigeons are to be put in "mm" number of pigeonholes and n>m. Let us assume that there is no pigeonhole with at least n/m pigeons. In this case, each and every pigeonhole will have less than n/m pigeons. Therefore, we have Number of pigeons in each pigeonhole < n/m Total number of pigeons < number of pigeonhole x n/m Total number of pigeons < m* n/m Total number of pigeons < n But given that number of pigeons are strictly equal to n. Which is a contradiction to our assumption. Hence there exists at least one pigeonhole having at least n/m pigeons. This proves the generalized form of pigeonhole principle.
Prove that language L= {a n b n : n 0} is not regular Q.2 (b) (i) If G=({s},{a},{S SS},S).Find the language generated by G. (ii) Show that L= {a n n is prime number} is not regular. (08) (i) (ii) L=ϕ. Prove that L = {a n : n is a prime number} is not regular. a. We don't know m, but assume there is one. b. Choose a string w = a n where n is a prime number and xyz = n > m+1. (This can always be done because there is no largest prime number.) Any prefix of w consists entirely of a's. c. We don't know the decomposition of w into xyz, but since xy m, it follows that z > 1. As usual, y > 0, d. Since z > 1, xz > 1. Choose i = xz. Then xy i z = xz + y xz = (1 + y ) xz. Since (1 + y ) and xz are each greater than 1, the product must be a composite number. Thus xy i z is a composite number. Unit-3 Q.3 Show that grammar S ab/ab, A aab/a, B ABb/b is ambiguous. Consider a srting w=aaabbb Constructing derivation tree for this string (08) CO363.3
As we get two derivation trees for the string w=aaabbb hence this grammar is ambiguous. OR Q.3 The productions of any grammar is given by: S 0B/1A A 0/0S/1AA B 1/ 1S/0BB For the string 00110101, Find the leftmost derivation, Rightmost derivation and derivation tree. (08) CO363.3