AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

Similar documents
AC68 FINITE AUTOMATA & FORMULA LANGUAGES JUNE 2014

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Foundations of Informatics: a Bridging Course

Theory of Computation Turing Machine and Pushdown Automata

SYLLABUS. Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 3 : REGULAR EXPRESSIONS AND LANGUAGES

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018

Section 1 (closed-book) Total points 30

Please give details of your answer. A direct answer without explanation is not counted.

What languages are Turing-decidable? What languages are not Turing-decidable? Is there a language that isn t even Turingrecognizable?

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

(b) If G=({S}, {a}, {S SS}, S) find the language generated by G. [8+8] 2. Convert the following grammar to Greibach Normal Form G = ({A1, A2, A3},

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs

INSTITUTE OF AERONAUTICAL ENGINEERING

Theory of Computation

October 6, Equivalence of Pushdown Automata with Context-Free Gramm

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

(pp ) PDAs and CFGs (Sec. 2.2)

Undecidable Problems and Reducibility

St.MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad

Question Bank UNIT I

VTU QUESTION BANK. Unit 1. Introduction to Finite Automata. 1. Obtain DFAs to accept strings of a s and b s having exactly one a.

Computational Models - Lecture 5 1

(pp ) PDAs and CFGs (Sec. 2.2)

CS154 Final Examination

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen

Post s Correspondence Problem (PCP) Is Undecidable. Presented By Bharath Bhushan Reddy Goulla

The Turing Machine. Computability. The Church-Turing Thesis (1936) Theory Hall of Fame. Theory Hall of Fame. Undecidability

Theory of Computation

1. (a) Explain the procedure to convert Context Free Grammar to Push Down Automata.

An automaton with a finite number of states is called a Finite Automaton (FA) or Finite State Machine (FSM).

Computational Models - Lecture 4

Theory Bridge Exam Example Questions

Theory of Computation (IV) Yijia Chen Fudan University

Theory of Computation (Classroom Practice Booklet Solutions)

The Post Correspondence Problem

SCHEME FOR INTERNAL ASSESSMENT TEST 3

ACS2: Decidability Decidability

Automata and Formal Languages - CM0081 Non-Deterministic Finite Automata

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

CSE 355 Test 2, Fall 2016

CPSC 421: Tutorial #1

Part 4 out of 5 DFA NFA REX. Automata & languages. A primer on the Theory of Computation. Last week, we showed the equivalence of DFA, NFA and REX

Let P(n) be a statement about a non-negative integer n. Then the principle of mathematical induction is that P(n) follows from

CSE 105 THEORY OF COMPUTATION

Introduction to Theory of Computing

CS154 Final Examination

HKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed

CFGs and PDAs are Equivalent. We provide algorithms to convert a CFG to a PDA and vice versa.

Theory of Computation - Module 3

CSCE 551: Chin-Tser Huang. University of South Carolina

Cliff s notes for equivalence of CFLs and L(PDAs) LisaCFL L = L(M) for some PDA M L=L(M)forsomePDAM L = L(G) for some CFG G

CSE 105 THEORY OF COMPUTATION

CISC 4090 Theory of Computation

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS

Solution Scoring: SD Reg exp.: a(a

Lecture 17: Language Recognition

1. Draw a parse tree for the following derivation: S C A C C A b b b b A b b b b B b b b b a A a a b b b b a b a a b b 2. Show on your parse tree u,

CS311 Computational Structures More about PDAs & Context-Free Languages. Lecture 9. Andrew P. Black Andrew Tolmach

1. Provide two valid strings in the languages described by each of the following regular expressions, with alphabet Σ = {0,1,2}.

V Honors Theory of Computation

NPDA, CFG equivalence

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

Pushdown Automata. Reading: Chapter 6

DM17. Beregnelighed. Jacob Aae Mikkelsen

CISC4090: Theory of Computation

CISC 4090 Theory of Computation

CPS 220 Theory of Computation

Einführung in die Computerlinguistik

Einführung in die Computerlinguistik

2.1 Solution. E T F a. E E + T T + T F + T a + T a + F a + a

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Sri vidya college of engineering and technology

Miscellaneous. Closure Properties Decision Properties

CPS 220 Theory of Computation Pushdown Automata (PDA)

SFWR ENG 2FA3. Solution to the Assignment #4

Note: In any grammar here, the meaning and usage of P (productions) is equivalent to R (rules).

The Pumping Lemma. for all n 0, u 1 v n u 2 L (i.e. u 1 u 2 L, u 1 vu 2 L [but we knew that anyway], u 1 vvu 2 L, u 1 vvvu 2 L, etc.

CSE 105 THEORY OF COMPUTATION

CpSc 421 Final Exam December 15, 2006

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.

60-354, Theory of Computation Fall Asish Mukhopadhyay School of Computer Science University of Windsor

Decidability (What, stuff is unsolvable?)

Definition: A grammar G = (V, T, P,S) is a context free grammar (cfg) if all productions in P have the form A x where

Properties of Context-Free Languages. Closure Properties Decision Properties

CS5371 Theory of Computation. Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)

Outline 1 PCP. 2 Decision problems about CFGs. M.Mitra (ISI) Post s Correspondence Problem 1 / 10

Turing s thesis: (1930) Any computation carried out by mechanical means can be performed by a Turing Machine

Pushdown Automata (Pre Lecture)

Intro to Theory of Computation

Non-context-Free Languages. CS215, Lecture 5 c

NODIA AND COMPANY. GATE SOLVED PAPER Computer Science Engineering Theory of Computation. Copyright By NODIA & COMPANY

Section 14.1 Computability then else

Computability Theory

Introduction to Formal Languages, Automata and Computability p.1/42

Automata and Computability. Solutions to Exercises

Concordia University Department of Computer Science & Software Engineering

Transcription:

Q.2 a. Prove by mathematical induction n 4 4n 2 is divisible by 3 for n 0. Basic step: For n = 0, n 3 n = 0 which is divisible by 3. Induction hypothesis: Let p(n) = n 3 n is divisible by 3. Induction step: Let us prove this for (n+1) also. Then p(n + 1) = (n + 1) 3 (n + 1) = (n 3 + 3n 2 + 3n + 1) (n + 1) = n 3 + 3n 2 + 3n n = (n 3 n) + 3(n 2 + n) Now (n 3 n) is divisible by 3 as p(n) is true by induction hypothesis. Also 3(n 2 + n) is a multiple of 3 and hence divisible by 3. Thus p(n) = n 3 n is divisible by 3 for all n 0. b. What is the need to study Automata Theory in computer science? Page Number 6, 7 of Text Book Q.3 a. Minimize the following DFA having state q 5 as final state: Present Next State State Input 0 Input 1 q 0 q 1 q 2 q 1 q 3 q 4 q 2 q 5 q 6 q 3 q 3 q 4 q 4 q 5 q 6 q 5 q 3 q 4 q 6 q 5 q 6 Q = {q 0, q 1, q 2, q 3, q 4, q 5, q 6 }, since q 5 is the final state. П 0 = (q 5, Q q 5 ) is the 0-equivalence class. Construction of 1-equivalence class: As δ(q 0, 0) = q 1 and δ(q 0, 1) = q 2, and both q 1 and q 2 are non final states. δ(q 1, 0) = q 3 and δ(q 1, 1) = q 4, and both q 3 and q 4 are non final states. Thus q 0 q 1 Proceeding in the same way, q 0 q 3 Thus q 0 q 1 q 3 Again δ(q 2, 0) = q 5 and δ(q 4, 0) = q 5 andδ(q 4, 1) = q 6, and δ(q 2, 1) = q 6, Hence q 2 q 4 and also q 4 q 6 Thus П 1 = [{q 5 }, {q 0, q 1, q 3 }, {q 2, q 4, q 6 }] is the 1-equivalence class. Similarly П 2 = [{q 5 }, {q 0, q 1, q 3 }, {q 2, q 4, q 6 }] is the 2-equivalence class also. Hence we have constructed the minimized sate automata as: Q = {[q 0, q 1, q 3 ], [q 2, q 4, q 6 ], [q 5 ]} and transition table is given below: State Input 0 1 [q 0, q 1, q 3 ] [q 0, q 1, [q 2, q 4, q 6 ] q 3 ] [q 2, q 4, q 6 ] [q 5 ] [q 2, q 4, q 6 ] IETE 1

[q 5 ] [q 0, q 1, q 3 ] [q 2, q 4, q 6 ] b. Design a finite automata for the language L = {w w is of even length and w (a, b) * }. We design the transition diagram as follows: a q 0 a q 1 b b b b a q 3 q 2 Where q 0 and q 2 are the two final states. Hence the finite machine is defined as: Q = {q 0, q 1, q 2, q 3 } Σ = (a, b) δ is the transition function given above. q 0 is the initial state. q 0 and q 2 are the two final states. Q.4 a. Let V N = {S, B}, V T = {a, b}, P = {S aba, B aba, B b}. Find the language L(G) generated by the given grammar. From the given productions we have: S aba aba, hence aba L(G). S aba aabaa aaabaaa.. aa abaa a a n ba n L(G). Hence { aba, aabaa, a 3 ba 3,., a n ba n } = {a n ba n n 1} L(G) (1) To show that L(G) {a n ba n n 1}, we start with w L(G), the derivation of w starts with S. If S aba is applied first and then B b, we get w = aba. On the other hand if we apply B aba ((n-1) times) and then finally to terminate this we apply B b, then w will be of the form a n ba n, So w { aba, aabaa, a 3 ba 3,., a n ba n }. Hence L(G) {a n ba n n 1}.(2) By (1) and (2) we have L(G) = {a n ba n n 1}. b. Obtain the NFA without epsilon transition corresponding to the following regular expression: 0 * 1(0 + 10 * 1) * Let us construct the NFA as follows: a IETE 2

0 * 1(0 + 10 * 1) * q 0 q f q 0 0 * 1 (0 + 10 * 1) * q 1 qf 0 0 1 1 q 0 q f q 1 0 State Q f is the final state. Hence the NFA M = ({q 0, q 1, q f }, {0, 1}, δ, {q 0 }, {q f }), the transition function δ is given above. Q.5 a. Construct a regular expression corresponding to the state diagram given below 1 There is only one initial state. Also, there are no null moves. The equations are: q 1 = q 1 0 + q 3 0 +.(1) q 2 = q 1 1 + q 2 1 + q 3 1..(2) q 3 = q 2 0 (3) So, q 2 = q 1 1 + q 2 1 + (q 2 0)1 = q 1 1 + q 2 (1 + 01) (put q 3 from eq. 3 to eq.2) Applying Arden s theorem, which says if there is an equation in regular expressions P, Q and R as R = Q + R.P, then the solution is given by R = Q.P *. q 2 = q 1 1.(1 + 01) * IETE 3

Also we have q 1 = q 1 0 + q 3 0 + = q 1 0 + (q 2 0)0 + (by eq. (3)) Put the value of q 2 here which we have obtained above, q1 = q 1 0 + (q 1 1(1 + 01) * 0)0 + = q 1 (0 + 1(1 + 01) * 00) + Thus q 1 = ((0 + 1(1 + 01) * 00) * = (0 + 1(1 + 01) * 00) * (By Arden s Theorem) As q 1 is the only final state, the regular expression corresponding to the given diagram is (0 + 1(1 + 01) * 00) *. b. Consider the following productions representing regular grammar G, S aa a A aa ab a B bb c Find the regular expression corresponding to regular grammar G. Let us construct the language by the given productions: S a hence string w = a L S aa aaa aaaa aaa.a n 1 A a n L. S aa aaa.. aaa.a n 1 A a n B a n c L. S aa aaa.. aaa.a n 1 A a n B a n bb. a n b m L. S aa aaa.. aaa.a n 1 A a n B a n bb. a n b m B a n b m c L. Hence L = {a n b m U a n b m c n 1, m 0} It s regular expression can be written as a + b * + a + b * c = a + b * (ε + c). Q.6 a. Construct a PDA to accept strings containing equal number of 0 s and 1 s by null store. Show the moves of the PDA for the input string 011001. Let M = {(q 0, q 1 ), Σ = (0, 1), (a, b, Z 0 ), δ, {q f }, q 0, Z 0 } where Z 0 is the special stack symbol which says that stack is empty. Now we write the push and pop operations as follows: Push Operations: 1. δ(q 0, 0, Z 0 ) = (q 0, 0Z 0 ) 2. δ(q 0, 1, Z 0 ) = (q 0, 1Z 0 ) 3. δ(q 0, 0, 0) = (q 0, 00) 4. δ(q 0, 1, 1) = (q 0, 11) This operation will store 0 s or 1 s in the stack. Pop Operations: 1. δ(q 0, 0, 1) = (q 0, ^) 2. δ(q 0, 1, 0) = (q 0, ^) 3. δ(q 0, ^, Z 0 ) = (q f, ^) (Accepting by null store) This operation will remove 0 s corresponding to 1 s on input tape and vice-versa. This is the required PDA. Now the processing of the given string 011001 as follows: δ(q 0, 011001, Z 0 ) ---- (q 0, 11001, 0Z 0 ) ---- (q 0, 1001, Z 0 ) ----- (q 0, 001, 1Z 0 ) ---- IETE 4

(q 0, 01, Z 0 ) ---- (q 0, 1, 0Z 0 ) ----- (q 0, ^, Z 0 ) = q f (the final state). Hence the given sting is accepted by the designed PDA. b. What is ambiguity? Show that S as Sa a is an ambiguous grammar. Ambiguity in CFG: A grammar is said to be ambiguous if for any string we have two left or right most derivation trees. For example, E E + E E * E can generate string E + E * E in two ways E E E + E E * E E * E E + E Two derivation trees with same yield Now to show that S as Sa a is ambiguous we need to construct two different trees for same string say w = aaaa. S as aas aaas aaaa (by S as a)..(1) S Sa Saa Saaa aaaa (by S Sa a)..(2) Hence there exist two different ie; one left most and another right most derivation trees for the given grammar, hence it is ambiguous. Q.7 a. What are applications of pumping lemma in Chomsky s normal form? Convert the given grammar into Chomsky s Nf. S ASB, A aas a, B SbS bb Page Number 127 of Text Book b. Find a reduced grammar equivalent to G = (V N, Σ, P, S) where set P is given as follows: S AB, A a, B b C, D c Step 1(Removal of extra variables) Construction of V N : Let us construct W 1 = {A, B, D as A a, B b and D c are productions with a terminal string on the R.H.S. } W 2 = W 1 {X V N X α for some α ( W 1 * Σ)} = { S, A, B, D} Similarly W 3 = W 2 {X V N X α for some α ( W 2 * Σ)} = W 2 φ = W 2 Therefore V N = {S, A, B, D} and hence P = S AB, A a, B b, D c. IETE 5

Thus G = (V N, Σ, P, S) Step 2(Removal of useless productions) Construction of V N : W 1 = {S} W 2 = W 1 {X V N Σ there is a production A α with A W 1 and α containing X} W 2 = {S} {A, B} = {S, A, B} W 3 = W 2 {a, b} = {S, A, B, a, b} W 4 = W 3 Thus V N = {S, A, B} and P = S AB, A a, B b. Hence reduced grammar G = {V N = {S, A, B}, Σ = (a, b), P, S} Q.8 a. Design a Turing machine that recognizes all strings of even length over Σ = (a, b) * We construct the machine as follows: (a, e, R), (b, e, R) q 0 q 1 (a, e, R), (b, e, R) To accept all strings over (a, b) of even length, we need two states to construct a loop from one to another. Let q 0 be the initial and final state. On reading either a or b at state q 0 machine goes to q 1 writes e (empty) on the input tape and moves to right direction. Similarly On reading either a or b at q 1 machine writes e (empty) on the input tape goes to state q 0 and moves to right direction. Hence it accepts all strings of even length over (a, b) *. Hence TM M = {(q 0, q 1 ), (a, b), q 0, δ, Γ = (a, b, e), (L / R), {q 0 }} where the transition function δ is defined as above. It can be defined as transition table as follows: State Input a b q 0 e,r,q 1 e,r,q 1 q 1 e,r,q 0 e,r,q 0 b. Write short note on universal Turing machine. A universal Turing machine is one that can be used to simulate any other Turing machine. There exists a \universal" Turing machine U that, on input <M, w> where M is a TM and w is a sting over (0, 1) *, simulates the computation of M on input w. Specifically: 1. U accepts <M, w> iff M accepts w 2. U rejects <M, w> iff M rejects w IETE 6

Q.9 a. Prove that if a language L and it s complement L are both recursively enumerable, then L is recursive. Let TM 1 and TM 2 accept L and L respectively. Let us construct a turing machine TM which simulate TM 1 and TM 2 simultaneously. TM accepts w if TM 1 accepts it and rejects w if TM 2 will accepts it. Thus TM will always say either yes or no, but not both. Note that there is not a priority limit on how long it may take before TM 1 or TM 2 accepts, but it is certain that one or the other will do so. Since TM is algorithm that accepts L, it follows that L is recursive. w TM 1 Yes Yes TM 2 No Yes \ b. Define Post corresponding Problem (PCP). Check whether the following instance has no solution over Σ = {0, 1}. X and Y be the lists of the three strings as follows: List A List B i w i x i 1 1 111 2 10111 10 3 10 0 PCP: An instance of PCP consists of two lines of strings over some alphabet Σ; the two lists must be equal length. We generally refer to the A and B lists, and write A = w 1, w 2,,w k and B = x 1, x 2,,x k, for some integer k. For each i, the pair (w i, x i ) is said to be a corresponding pair. We say this instance of PCP has a solution, if there is a sequence of one or more integers i 1,i 2,, i m that, when interpreted as indexes for strings in the A and B lists, yield the same string. That is, w i1 w i2 w im = x i1 x i2 x im. We say the sequence i 1, i 2,.,i m is a solution to this instance of PCP, if so. The Post correspondence problem is: Given an instance of PCP, tell whether this has a solution. Consider the problem given above IETE 7

List A List B i w i x i 1 1 111 2 10111 10 3 10 0 Let m = 4, i 1 = 2, i 2 = 1, i 3 = 1, and i 4 = 3, i.e; the solution is the list 2, 1, 1, 3. This list is a solution by concatenating the corresponding strings in order for the two lists. That is, w 2 w 1 w 1 w 3 = x 2 x 1 x 1 x 3 = 101111110. Thus, in this case PCP has a solution. Text Book Introduction to Automata Theory, Languages and Computation, John E Hopcroft, Rajeev Motwani, Jeffery D. Ullman, Pearson Education, Third Edition, 2006 IETE 8