Homework 5 - Solution
|
|
- Shanon Small
- 5 years ago
- Views:
Transcription
1 DCP3122 Introduction to Formal Languages, Spring 2015 Instructor: Prof. Wen-Guey Tzeng Homework 5 - Solution 5-May-2015 Due: 18-May Given Σ = {a, b, c}, find an NPDA that accepts L = {a n b n+m c m : n 0, m 1}. Ans. An NPDA that accepts L is M = (Q, Σ, Γ, δ, q 0, z, F ), where Q = {q 0, q 1,..., q 5 }, Σ = {a, b, c}, Γ = {0, 1, z}, F = {q 5 }, and the transition function δ is represented as the following graph 2. Given Σ = {a, b, c}, find an NPDA that accepts L = {w 1 cw 2 : w 1, w 2 {a, b}, w 1 w R 2 }. Ans. An NPDA that accepts L is M = (Q, Σ, Γ, δ, q 0, z, F ), where Q = {q 0, q 1, q 2 }, Σ = {a, b, c}, Γ = {0, 1, z}, F = {q 2 }, and the transition function δ is represented as the following graph 3. What language is accepted by the PDA M = ({q 0, q 1,..., q 5 }, {a, b}, {0, 1, a, z}, δ, z, q 0, {q 5 }), 1-1
2 with δ(q 0, b, z) = {(q 1, 1z)}, δ(q 1, b, 1) = {(q 1, 11)}, δ(q 2, a, 1) = {(q 3, λ)}, δ(q 3, a, 1) = {(q 4, λ)}, δ(q 4, a, z) = {(q 4, z), (q 5, z)}? Ans. L =, because the transition function would never reach the final state. 4. Construct an NPDA that accepts the language generated by the grammar S asbb aab. Ans. The Greibach normal form of the grammar is S asbb aab, B b, A a. An NPDA that accepts L is M = (Q, Σ, Γ, δ, q 0, z, F ), where Q = {q 0, q 1, q 2 }, Σ = {a, b}, Γ = {S, A, B, z}, F = {q 2 }, and the transition function δ is represented as the following graph 5. Find a context-free grammar that generates the language accepted by the NPDA M = ({q 0, q 1 }, {a, b}, {A, z}, δ, q 0, z, {q 1 }), with transitions δ(q 0, a, z) = {(q 0, Az)}, δ(q 0, b, A) = {(q 0, AA)}, δ(q 0, a, A) = {(q 1, λ)}. Ans. We first transform the NPDA into a new one that satisfies the following two requirements: (1) It has a single final state q f that is entered if and only if the stack is empty; (2) While a Σ {λ}, all transitions must have the form δ(q i, a, A) = {c 1, c 2,..., c n }, where c i = (q j, λ) or c i = (q j, BC). The NPDA satisfies requirement (2), but not (1). To satisfy the latter, we introduce a new final state q 2 so that Q new = {q 0, q 1, q 2 }, F new = {q 2 }, and δ new is δ(q 0, a, z) = {(q 0, Az)}, δ(q 0, b, A) = {(q 0, AA)}, δ(q 0, a, A) = {(q 1, λ)}, δ(q 1, λ, A) = {(q 1, λ)}, δ(q 1, λ, z) = {(q 2, λ)}. 1-2
3 The last three transitions yield the corresponding productions (q 0 Aq 1 ) a, (q 1 Aq 1 ) λ, (q 1 zq 2 ) λ. From the first two transitions we get the set of productions (q 0 zq 0 ) a(q 0 Aq 0 )(q 0 zq 0 ) a(q 0 Aq 1 )(q 1 zq 0 ) a(q 0 Aq 2 )(q 2 zq 0 ), (q 0 zq 1 ) a(q 0 Aq 0 )(q 0 zq 1 ) a(q 0 Aq 1 )(q 1 zq 1 ) a(q 0 Aq 2 )(q 2 zq 1 ), (q 0 zq 2 ) a(q 0 Aq 0 )(q 0 zq 2 ) a(q 0 Aq 1 )(q 1 zq 2 ) a(q 0 Aq 2 )(q 2 zq 2 ), (q 0 Aq 0 ) a(q 0 Aq 0 )(q 0 Aq 0 ) a(q 0 Aq 1 )(q 1 Aq 0 ) a(q 0 Aq 2 )(q 2 Aq 0 ), (q 0 Aq 1 ) a(q 0 Aq 0 )(q 0 Aq 1 ) a(q 0 Aq 1 )(q 1 Aq 1 ) a(q 0 Aq 2 )(q 2 Aq 1 ), (q 0 Aq 2 ) a(q 0 Aq 0 )(q 0 Aq 2 ) a(q 0 Aq 1 )(q 1 Aq 2 ) a(q 0 Aq 2 )(q 2 Aq 2 ). To simplify the transitions, we remove the useless variables: A variable that does not occur on the left side of any production: (q 1 zq 0 ), (q 1 zq 1 ), (q 1 zq 2 ), (q 2 zq 0 ), (q 2 zq 1 ), (q 2 zq 2 ), (q 1 Aq 0 ), (q 1 Aq 1 ), (q 1 Aq 2 ), (q 2 Aq 0 ), (q 2 Aq 1 ), and (q 2 Aq 2 ). Non-reachable path: None. The result grammar is with the start variable is (q 0 zq 2 ). (q 0 Aq 1 ) a, (q 1 Aq 1 ) λ, (q 1 zq 2 ) λ, (q 0 zq 0 ) a(q 0 Aq 0 )(q 0 zq 0 ), (q 0 zq 1 ) a(q 0 Aq 0 )(q 0 zq 1 ), (q 0 zq 2 ) a(q 0 Aq 0 )(q 0 zq 2 ), (q 0 Aq 0 ) a(q 0 Aq 0 )(q 0 Aq 0 ), (q 0 Aq 1 ) a(q 0 Aq 0 )(q 0 Aq 1 ), (q 0 Aq 2 ) a(q 0 Aq 0 )(q 0 Aq 2 ), 6. Show that the language L = {w {a, b, c} : n a (w) = n b (w) n c (w)} is not context-free. Ans. We pick a string w = a m b m c m L, m N. There are many ways to decompose w as w = uvxyz with vxy m and vy 1. However, for all of them have a winning countermove such that uv i xy i z / L: v = a k, y = a k : uv 0 xy 0 z = a m 2k b m c m / L. v = a k, y = a k b k : uv 0 xy 0 z = a m 2k b m k c m / L. v = a k, y = b l : uv 0 xy 0 z = a m k b m l c m / L. v = a k b k, y = b k : uv 0 xy 0 z = a m k b m 2k c m / L. v = b k, y = b k : uv 0 xy 0 z = a m b m 2k c m / L. v = b k, y = b k c k : uv 0 xy 0 z = a m b m 2k c m k / L. 1-3
4 v = b k, y = c k uv 0 xy 0 z = a m b m k c m k / L. v = b k c k, y = c k : uv 0 xy 0 z = a m b m 2k c m k / L. v = c k, y = c k : uv 0 xy 0 z = a m b m c m 2k / L. 7. Show that the language L = {a n b m : n and m are both prime} is not context-free. Ans. We pick a string w = a m b m L, m is an odd prime. There are many ways to decompose w as w = uvxyz with vxy m and vy 1. However, for all of them have a winning countermove such that uv i xy i z / L: v = a k, y = a l with k + l is odd: uv 0 xy 0 z = a m k l b m / L since m k l is even. v = a k 1, y = a k 2 b l with one of k 1 and k 2 is odd, or l is odd: uv 0 xy 0 z = a m k 1 k 2 b m l / L since m k 1 k 2 is even or m l is even. v = a k, y = b l with one of k and l is odd: uv 0 xy 0 z = a m k b m l / L since m k is even or m l is even. v = a l b k 1, y = b k 2 with one of k 1 and k 2 is odd, or l is odd: uv 0 xy 0 z = a m l b m k 1 k 2 / L since m l is even or m k 1 k 2 is even. v = b k, y = b l with k + l is odd: uv 0 xy 0 z = a m b m k l / L since m k l is even. 8. Determine whether or not L = {a n b j a k b l : n k, j l} is context-free. You have to prove your answer. Ans. We pick a string w = a m b m a m b m L, m N. There are many ways to decompose w as w = uvxyz with vxy m and vy 1. However, for all of them have a winning countermove such that uv i xy i z / L: [1st a] v = a k, y = a k with k N: uv i xy i z = a m+2(i 1)k b m a m b m / L for i = 2, 3,.... [1st a, 1st b] v = a k, y = a k b k : uv i xy i z = a m+2(i 1)k b m+(i 1)k a m b m / L for i = 2, 3,.... [1st a, 1st b] v = a k, y = b k : uv i xy i z = a m+(i 1)k b m+(i 1)k a m b m / L for i = 2, 3,.... [1st a, 1st b] v = a k b k, y = b k : uv i xy i z = a m+(i 1)k b m+2(i 1)k a m b m / L for i = 2, 3,.... [1st b] v = b k, y = b k : uv i xy i z = a m b m+2(i 1)k a m b m / L for i = 2, 3,.... [1st b, 2nd a] v = b k, y = b k a k : uv i xy i z = a m b m+2(i 1)k a m+(i 1)k b m / L for i = 2, 3,.... [1st b, 2nd a] v = b k, y = a k : uv i xy i z = a m b m+(i 1)k a m+(i 1)k b m / L for i = 2, 3,.... [1st b, 2nd a] v = b k a k, y = a k : uv i xy i z = a m b m+(i 1)k a m+2(i 1)k b m / L for i = 2, 3,.... [2nd a] v = a k, y = a k : uv 0 xy 0 z = a m b m a m 2k b m / L. [2nd a, 2nd b] v = a k, y = a k b k : uv 0 xy 0 z = a m b m a m 2k b m k / L. [2nd a, 2nd b] v = a k, y = b k : uv 0 xy 0 z = a m b m a m k b m k / L. [2nd a, 2nd b] v = a k b k, y = b k : uv 0 xy 0 z = a m b m a m k b m 2k / L. [2nd b] v = b k, y = b k : uv 0 xy 0 z = a m b m a m b m 2k / L. 1-4
5 9. Show that the family of context-free languages is not closed under difference in general, but is closed under regular difference, that is, if L 1 is context-free and L 2 is regular, then L 1 L 2 is context-free. Ans. The answer contains the following two parts: Let L 1 and L 2 be context-free languages. By theorem, we have that the family of contextfree languages is not close under intersection and complement. Thus, L 1 L 2 = L 1 L 2 is not close under difference in general. Let L 1 be a context-free language and L 2 a regular language. By the closure property of regular languages, we know that L 2 is also regular. By theorem, we know that L 1 L 2 is context-free by the closure property under regular intersection. Therefore, L 1 L 2 = L 1 L 2 is also context-free by the closure property under regular intersection. 10. Show that L = {w {a, b} : n a (w) = n b (w); w does not contain a substring aab} is contextfree. Ans. Let L 1 = {w {a, b} : n a (w) = n b (w)} and L 2 = {w {a, b} : w contains aab as a string}. The following shows that L 1 is context-free and L 2 is regular. An NPDA that accepts L 1 is M 1 = ({q 0, q 1 }, {a, b}, {a, b, z}, δ, q 0, z, {q 1 }), where the transition function δ is defined as follows: δ(q 0, λ, z) = (q 1, z), δ(q 0, a, z) = (q 0, az), δ(q 0, a, a) = (q 0, aa), δ(q 0, a, b) = (q 0, λ), δ(q 0, b, z) = (q 0, bz), δ(q 0, b, a) = (q 0, λ), δ(q 0, b, b) = (q 0, bb). An NFA that accepts L 2 is M 2 = ({q 0, q 1, q 2, q 3 }, {a, b}, δ, q 0, {q 3 }) accepts L, where the transition function δ is defined as follows: δ(q 0, a) = q 1, δ(q 0, b) = q 0, δ(q 1, a) = q 2, δ(q 1, b) = q 0, δ(q 2, a) = q 0, δ(q 2, b) = q 3, δ(q 3, a) = q 3, δ(q 3, b) = q 3. Therefore, L = L 1 L 2 is context-free by the closure property under regular intersection. 1-5
Pushdown Automata. Notes on Automata and Theory of Computation. Chia-Ping Chen
Pushdown Automata Notes on Automata and Theory of Computation Chia-Ping Chen Department of Computer Science and Engineering National Sun Yat-Sen University Kaohsiung, Taiwan ROC Pushdown Automata p. 1
More information2.1 Solution. E T F a. E E + T T + T F + T a + T a + F a + a
. Solution E T F a E E + T T + T F + T a + T a + F a + a E E + T E + T + T T + T + T F + T + T a + T + T a + F + T a + a + T a + a + F a + a + a E T F ( E) ( T ) ( F) (( E)) (( T )) (( F)) (( a)) . Solution
More informationSimplification of CFG and Normal Forms. Wen-Guey Tzeng Computer Science Department National Chiao Tung University
Simplification of CFG and Normal Forms Wen-Guey Tzeng Computer Science Department National Chiao Tung University Normal Forms We want a cfg with either Chomsky or Greibach normal form Chomsky normal form
More informationSimplification of CFG and Normal Forms. Wen-Guey Tzeng Computer Science Department National Chiao Tung University
Simplification of CFG and Normal Forms Wen-Guey Tzeng Computer Science Department National Chiao Tung University Normal Forms We want a cfg with either Chomsky or Greibach normal form Chomsky normal form
More informationPumping Lemma for CFLs
Pumping Lemma for CFLs v y s Here we go again! Intuition: If L is CF, then some CFG G produces strings in L If some string in L is very long, it will have a very tall parse tree If a parse tree is taller
More informationContext-Free Languages (Pre Lecture)
Context-Free Languages (Pre Lecture) Dr. Neil T. Dantam CSCI-561, Colorado School of Mines Fall 2017 Dantam (Mines CSCI-561) Context-Free Languages (Pre Lecture) Fall 2017 1 / 34 Outline Pumping Lemma
More informationHomework 4 Solutions. 2. Find context-free grammars for the language L = {a n b m c k : k n + m}. (with n 0,
Introduction to Formal Language, Fall 2016 Due: 21-Apr-2016 (Thursday) Instructor: Prof. Wen-Guey Tzeng Homework 4 Solutions Scribe: Yi-Ruei Chen 1. Find context-free grammars for the language L = {a n
More informationCliff 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
What s on our plate today? 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 Pumping Lemma (one last time) Statement of Pumping
More informationFORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY REVIEW for MIDTERM 1 THURSDAY Feb 6 Midterm 1 will cover everything we have seen so far The PROBLEMS will be from Sipser, Chapters 1, 2, 3 It will be
More informationContext-Free and Noncontext-Free Languages
Examples: Context-Free and Noncontext-Free Languages a*b* is regular. A n B n = {a n b n : n 0} is context-free but not regular. A n B n C n = {a n b n c n : n 0} is not context-free The Regular and the
More informationFormal Languages, Automata and Models of Computation
CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2011 1 Content - More Properties of Regular Languages (RL)
More informationClosure under the Regular Operations
September 7, 2013 Application of NFA Now we use the NFA to show that collection of regular languages is closed under regular operations union, concatenation, and star Earlier we have shown this closure
More informationCSE 355 Test 2, Fall 2016
CSE 355 Test 2, Fall 2016 28 October 2016, 8:35-9:25 a.m., LSA 191 Last Name SAMPLE ASU ID 1357924680 First Name(s) Ima Regrading of Midterms If you believe that your grade has not been added up correctly,
More informationHarvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs
Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs Harry Lewis October 8, 2013 Reading: Sipser, pp. 119-128. Pushdown Automata (review) Pushdown Automata = Finite automaton
More informationHomework 4. Chapter 7. CS A Term 2009: Foundations of Computer Science. By Li Feng, Shweta Srivastava, and Carolina Ruiz
CS3133 - A Term 2009: Foundations of Computer Science Prof. Carolina Ruiz Homework 4 WPI By Li Feng, Shweta Srivastava, and Carolina Ruiz Chapter 7 Problem: Chap 7.1 part a This PDA accepts the language
More informationCS 341 Homework 16 Languages that Are and Are Not Context-Free
CS 341 Homework 16 Languages that Are and Are Not Context-Free 1. Show that the following languages are context-free. You can do this by writing a context free grammar or a PDA, or you can use the closure
More informationComputational Models - Lecture 4
Computational Models - Lecture 4 Regular languages: The Myhill-Nerode Theorem Context-free Grammars Chomsky Normal Form Pumping Lemma for context free languages Non context-free languages: Examples Push
More informationCS500 Homework #2 Solutions
CS500 Homework #2 Solutions 1. Consider the two languages Show that L 1 is context-free but L 2 is not. L 1 = {a i b j c k d l i = j k = l} L 2 = {a i b j c k d l i = k j = l} Answer. L 1 is the concatenation
More informationHW 3 Solutions. Tommy November 27, 2012
HW 3 Solutions Tommy November 27, 2012 5.1.1 (a) Online solution: S 0S1 ɛ. (b) Similar to online solution: S AY XC A aa ɛ b ɛ C cc ɛ X axb aa b Y by c b cc (c) S X A A A V AV a V V b V a b X V V X V (d)
More informationÖVNINGSUPPGIFTER I SAMMANHANGSFRIA SPRÅK. 17 april Classrum Edition
ÖVNINGSUPPGIFTER I SAMMANHANGSFRIA SPRÅK 7 april 23 Classrum Edition CONTEXT FREE LANGUAGES & PUSH-DOWN AUTOMATA CONTEXT-FREE GRAMMARS, CFG Problems Sudkamp Problem. (3.2.) Which language generates the
More informationAutomata Theory. CS F-10 Non-Context-Free Langauges Closure Properties of Context-Free Languages. David Galles
Automata Theory CS411-2015F-10 Non-Context-Free Langauges Closure Properties of Context-Free Languages David Galles Department of Computer Science University of San Francisco 10-0: Fun with CFGs Create
More informationSolution Scoring: SD Reg exp.: a(a
MA/CSSE 474 Exam 3 Winter 2013-14 Name Solution_with explanations Section: 02(3 rd ) 03(4 th ) 1. (28 points) For each of the following statements, circle T or F to indicate whether it is True or False.
More informationPushdown Automata. We have seen examples of context-free languages that are not regular, and hence can not be recognized by finite automata.
Pushdown Automata We have seen examples of context-free languages that are not regular, and hence can not be recognized by finite automata. Next we consider a more powerful computation model, called a
More informationComputability and Complexity
Computability and Complexity Push-Down Automata CAS 705 Ryszard Janicki Department of Computing and Software McMaster University Hamilton, Ontario, Canada janicki@mcmaster.ca Ryszard Janicki Computability
More informationCS 154 Formal Languages and Computability Assignment #2 Solutions
CS 154 Formal Languages and Computability Assignment #2 Solutions Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak www.cs.sjsu.edu/~mak Assignment #2: Question 1
More informationIntroduction to Formal Languages, Automata and Computability p.1/42
Introduction to Formal Languages, Automata and Computability Pushdown Automata K. Krithivasan and R. Rama Introduction to Formal Languages, Automata and Computability p.1/42 Introduction We have considered
More informationNPDA, CFG equivalence
NPDA, CFG equivalence Theorem A language L is recognized by a NPDA iff L is described by a CFG. Must prove two directions: ( ) L is recognized by a NPDA implies L is described by a CFG. ( ) L is described
More informationMA/CSSE 474 Theory of Computation
MA/CSSE 474 Theory of Computation Bottom-up parsing Pumping Theorem for CFLs Recap: Going One Way Lemma: Each context-free language is accepted by some PDA. Proof (by construction): The idea: Let the stack
More informationCS5371 Theory of Computation. Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL, DPDA PDA)
CS5371 Theory of Computation Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL, DPDA PDA) Objectives Introduce the Pumping Lemma for CFL Show that some languages are non- CFL Discuss the DPDA, which
More informationMore Properties of Regular Languages
More Properties of Regular anguages 1 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse 2 Namely, for regular languages 1 and 2 : Union 1 2 Concatenation Star
More informationSection 1 (closed-book) Total points 30
CS 454 Theory of Computation Fall 2011 Section 1 (closed-book) Total points 30 1. Which of the following are true? (a) a PDA can always be converted to an equivalent PDA that at each step pops or pushes
More informationIntro to Theory of Computation
Intro to Theory of Computation LECTURE 9 Last time: Converting a PDA to a CFG Pumping Lemma for CFLs Today: Pumping Lemma for CFLs Review of CFGs/PDAs Sofya Raskhodnikova 2/9/2016 Sofya Raskhodnikova;
More informationSheet 1-8 Dr. Mostafa Aref Format By : Mostafa Sayed
Sheet -8 Dr. Mostafa Aref Format By : Mostafa Sayed 09 Introduction Assignment. For = {a, } a) Write 0 strings of the following languages i) All strings with no more than one a,,, a, a, a, a, a, a, a ii)
More informationTheory of Computation (IV) Yijia Chen Fudan University
Theory of Computation (IV) Yijia Chen Fudan University Review language regular context-free machine DFA/ NFA PDA syntax regular expression context-free grammar Pushdown automata Definition A pushdown automaton
More informationTheory of Computation - Module 3
Theory of Computation - Module 3 Syllabus Context Free Grammar Simplification of CFG- Normal forms-chomsky Normal form and Greibach Normal formpumping lemma for Context free languages- Applications of
More informationProperties of Regular Languages. Wen-Guey Tzeng Department of Computer Science National Chiao Tung University
Properties of Regular Languages Wen-Guey Tzeng Department of Computer Science National Chiao Tung University Closure Properties Question: L is a regular language and op is an operator on strings. Is op(l)
More informationTheory of Computation
Fall 2002 (YEN) Theory of Computation Midterm Exam. Name:... I.D.#:... 1. (30 pts) True or false (mark O for true ; X for false ). (Score=Max{0, Right- 1 2 Wrong}.) (1) X... If L 1 is regular and L 2 L
More informationIntroduction to Theory of Computing
CSCI 2670, Fall 2012 Introduction to Theory of Computing Department of Computer Science University of Georgia Athens, GA 30602 Instructor: Liming Cai www.cs.uga.edu/ cai 0 Lecture Note 3 Context-Free Languages
More informationThe View Over The Horizon
The View Over The Horizon enumerable decidable context free regular Context-Free Grammars An example of a context free grammar, G 1 : A 0A1 A B B # Terminology: Each line is a substitution rule or production.
More informationCISC4090: Theory of Computation
CISC4090: Theory of Computation Chapter 2 Context-Free Languages Courtesy of Prof. Arthur G. Werschulz Fordham University Department of Computer and Information Sciences Spring, 2014 Overview In Chapter
More informationChapter 6. Properties of Regular Languages
Chapter 6 Properties of Regular Languages Regular Sets and Languages Claim(1). The family of languages accepted by FSAs consists of precisely the regular sets over a given alphabet. Every regular set is
More informationFinite Automata and Regular languages
Finite Automata and Regular languages Huan Long Shanghai Jiao Tong University Acknowledgements Part of the slides comes from a similar course in Fudan University given by Prof. Yijia Chen. http://basics.sjtu.edu.cn/
More informationGEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I
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
More informationClosure Properties of Context-Free Languages. Foundations of Computer Science Theory
Closure Properties of Context-Free Languages Foundations of Computer Science Theory Closure Properties of CFLs CFLs are closed under: Union Concatenation Kleene closure Reversal CFLs are not closed under
More informationComputational Models - Lecture 3 1
Computational Models - Lecture 3 1 Handout Mode Iftach Haitner and Yishay Mansour. Tel Aviv University. March 13/18, 2013 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice
More informationCpSc 421 Final Exam December 15, 2006
CpSc 421 Final Exam December 15, 2006 Do problem zero and six of problems 1 through 9. If you write down solutions for more that six problems, clearly indicate those that you want graded. Note that problems
More informationFORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
5-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY NON-DETERMINISM and REGULAR OPERATIONS THURSDAY JAN 6 UNION THEOREM The union of two regular languages is also a regular language Regular Languages Are
More informationDefinition: A grammar G = (V, T, P,S) is a context free grammar (cfg) if all productions in P have the form A x where
Recitation 11 Notes Context Free Grammars Definition: A grammar G = (V, T, P,S) is a context free grammar (cfg) if all productions in P have the form A x A V, and x (V T)*. Examples Problem 1. Given the
More informationPUSHDOWN AUTOMATA (PDA)
PUSHDOWN AUTOMATA (PDA) FINITE STATE CONTROL INPUT STACK (Last in, first out) input pop push ε,ε $ 0,ε 0 1,0 ε ε,$ ε 1,0 ε PDA that recognizes L = { 0 n 1 n n 0 } Definition: A (non-deterministic) PDA
More informationProperties of Context Free Languages
1 Properties of Context Free Languages Pallab Dasgupta, Professor, Dept. of Computer Sc & Engg 2 Theorem: CFLs are closed under concatenation If L 1 and L 2 are CFLs, then L 1 L 2 is a CFL. Proof: 1. Let
More informationCS5371 Theory of Computation. Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL)
CS5371 Theory of Computation Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL) Objectives Introduce Pumping Lemma for CFL Apply Pumping Lemma to show that some languages are non-cfl Pumping Lemma
More informationSolution to CS375 Homework Assignment 11 (40 points) Due date: 4/26/2017
Solution to CS375 Homework Assignment 11 (40 points) Due date: 4/26/2017 1. Find a Greibach normal form for the following given grammar. (10 points) S bab A BAa a B bb Ʌ Solution: (1) Since S does not
More informationTheory of Computation (Classroom Practice Booklet Solutions)
Theory of Computation (Classroom Practice Booklet Solutions) 1. Finite Automata & Regular Sets 01. Ans: (a) & (c) Sol: (a) The reversal of a regular set is regular as the reversal of a regular expression
More informationHW6 Solutions. Micha l Dereziński. March 20, 2015
HW6 Solutions Micha l Dereziński March 20, 2015 1 Exercise 5.5 (a) The PDA accepts odd-length strings whose middle symbol is a and whose other letters are as and bs. Its diagram is below. b, Z 0 /XZ 0
More informationThe Pumping Lemma for Context Free Grammars
The Pumping Lemma for Context Free Grammars Chomsky Normal Form Chomsky Normal Form (CNF) is a simple and useful form of a CFG Every rule of a CNF grammar is in the form A BC A a Where a is any terminal
More information6.8 The Post Correspondence Problem
6.8. THE POST CORRESPONDENCE PROBLEM 423 6.8 The Post Correspondence Problem The Post correspondence problem (due to Emil Post) is another undecidable problem that turns out to be a very helpful tool for
More informationContext-free Languages and Pushdown Automata
Context-free Languages and Pushdown Automata Finite Automata vs CFLs E.g., {a n b n } CFLs Regular From earlier results: Languages every regular language is a CFL but there are CFLs that are not regular
More informationCS 154. Finite Automata, Nondeterminism, Regular Expressions
CS 54 Finite Automata, Nondeterminism, Regular Expressions Read string left to right The DFA accepts a string if the process ends in a double circle A DFA is a 5-tuple M = (Q, Σ, δ, q, F) Q is the set
More informationRecitation 4: Converting Grammars to Chomsky Normal Form, Simulation of Context Free Languages with Push-Down Automata, Semirings
Recitation 4: Converting Grammars to Chomsky Normal Form, Simulation of Context Free Languages with Push-Down Automata, Semirings 11-711: Algorithms for NLP October 10, 2014 Conversion to CNF Example grammar
More informationClosure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism
Closure Properties of Regular Languages Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism Closure Properties Recall a closure property is a statement
More informationProperties of context-free Languages
Properties of context-free Languages We simplify CFL s. Greibach Normal Form Chomsky Normal Form We prove pumping lemma for CFL s. We study closure properties and decision properties. Some of them remain,
More informationCS 154, Lecture 3: DFA NFA, Regular Expressions
CS 154, Lecture 3: DFA NFA, Regular Expressions Homework 1 is coming out Deterministic Finite Automata Computation with finite memory Non-Deterministic Finite Automata Computation with finite memory and
More informationLecture 12 Simplification of Context-Free Grammars and Normal Forms
Lecture 12 Simplification of Context-Free Grammars and Normal Forms COT 4420 Theory of Computation Chapter 6 Normal Forms for CFGs 1. Chomsky Normal Form CNF Productions of form A BC A, B, C V A a a T
More information(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},
Code No: 07A50501 R07 Set No. 2 III B.Tech I Semester Examinations,MAY 2011 FORMAL LANGUAGES AND AUTOMATA THEORY Computer Science And Engineering Time: 3 hours Max Marks: 80 Answer any FIVE Questions All
More information3.13. PUSHDOWN AUTOMATA Pushdown Automata
3.13. PUSHDOWN AUTOMATA 317 3.13 Pushdown Automata We have seen that the regular languages are exactly the languages accepted by DFA s or NFA s. The context-free languages are exactly the languages accepted
More informationFinal exam study sheet for CS3719 Turing machines and decidability.
Final exam study sheet for CS3719 Turing machines and decidability. A Turing machine is a finite automaton with an infinite memory (tape). Formally, a Turing machine is a 6-tuple M = (Q, Σ, Γ, δ, q 0,
More informationAC68 FINITE AUTOMATA & FORMULA LANGUAGES JUNE 2014
Q.2 a. Show by using Mathematical Induction that n i= 1 i 2 n = ( n + 1) ( 2 n + 1) 6 b. Define language. Let = {0; 1} denote an alphabet. Enumerate five elements of the following languages: (i) Even binary
More informationProblem 2.6(d) [4 pts] Problem 2.12 [3pts] Original CFG:
Problem 2.6(d) [4 pts] S X T#X X#T T#X#T X axa bxb #T# # T at bt #T ε Problem 2.12 [3pts] Original CFG: R XRX S S atb bta T XTX X ε X a b q start ε, ε $ ε, R X ε, ε R ε, ε X ε, R S ε, T X ε, T ε ε, X a
More informationVTU QUESTION BANK. Unit 1. Introduction to Finite Automata. 1. Obtain DFAs to accept strings of a s and b s having exactly one a.
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.(5m )( Dec-2014) 2. Obtain a DFA to accept strings of a s and b s having even
More informationDM17. Beregnelighed. Jacob Aae Mikkelsen
DM17 Beregnelighed Jacob Aae Mikkelsen January 12, 2007 CONTENTS Contents 1 Introduction 2 1.1 Operations with languages...................... 2 2 Finite Automata 3 2.1 Regular expressions/languages....................
More informationFunctions on languages:
MA/CSSE 474 Final Exam Notation and Formulas page Name (turn this in with your exam) Unless specified otherwise, r,s,t,u,v,w,x,y,z are strings over alphabet Σ; while a, b, c, d are individual alphabet
More informationCS375 Midterm Exam Solution Set (Fall 2017)
CS375 Midterm Exam Solution Set (Fall 2017) Closed book & closed notes October 17, 2017 Name sample 1. (10 points) (a) Put in the following blank the number of strings of length 5 over A={a, b, c} that
More informationCSE 105 Homework 5 Due: Monday November 13, Instructions. should be on each page of the submission.
CSE 05 Homework 5 Due: Monday November 3, 207 Instructions Upload a single file to Gradescope for each group. should be on each page of the submission. All group members names and PIDs Your assignments
More informationTHEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET
THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET Regular Languages and FA A language is a set of strings over a finite alphabet Σ. All languages are finite or countably infinite. The set of all languages
More informationComputability Theory
CS:4330 Theory of Computation Spring 2018 Computability Theory Decidable Problems of CFLs and beyond Haniel Barbosa Readings for this lecture Chapter 4 of [Sipser 1996], 3rd edition. Section 4.1. Decidable
More informationFORMAL LANGUAGES, AUTOMATA AND COMPUTATION
FORMAL LANGUAGES, AUTOMATA AND COMPUTATION IDENTIFYING NONREGULAR LANGUAGES PUMPING LEMMA Carnegie Mellon University in Qatar (CARNEGIE MELLON UNIVERSITY IN QATAR) SLIDES FOR 15-453 LECTURE 5 SPRING 2011
More informationOgden s Lemma for CFLs
Ogden s Lemma for CFLs Theorem If L is a context-free language, then there exists an integer l such that for any u L with at least l positions marked, u can be written as u = vwxyz such that 1 x and at
More informationIndexed Languages and why you care. Presented by Pieter Hooimeijer
Indexed Languages and why you care Presented by Pieter Hooimeijer 2008-02-07 1 Think Way Back... www.xkcd.com 2 ...Far Enough:... CS NCF DCF REG REG 3 Formal Language Classes... CS NCF DCF REG REG PDA
More informationDeterministic PDA s. Deepak D Souza. 08 Nov Department of Computer Science and Automation Indian Institute of Science, Bangalore.
Deterministic PDA s Deepak D Souza Department of Computer Science and Automation Indian Institute of Science, Bangalore. 08 Nov 2016 Outline 1 Deterministic PDA s 2 Closure properties of DCFL s 3 Complementing
More informationBASIC MATHEMATICAL TECHNIQUES
CHAPTER 1 ASIC MATHEMATICAL TECHNIQUES 1.1 Introduction To understand automata theory, one must have a strong foundation about discrete mathematics. Discrete mathematics is a branch of mathematics dealing
More informationQuestion Bank UNIT I
Siddhivinayak Technical Campus School of Engineering & Research Technology Department of computer science and Engineering Session 2016-2017 Subject Name- Theory of Computation Subject Code-4KS05 Sr No.
More informationNODIA AND COMPANY. GATE SOLVED PAPER Computer Science Engineering Theory of Computation. Copyright By NODIA & COMPANY
No part of this publication may be reproduced or distributed in any form or any means, electronic, mechanical, photocopying, or otherwise without the prior permission of the author. GATE SOLVED PAPER Computer
More informationFundamentele Informatica II
Fundamentele Informatica II Answer to selected exercises 5 John C Martin: Introduction to Languages and the Theory of Computation M.M. Bonsangue (and J. Kleijn) Fall 2011 5.1.a (q 0, ab, Z 0 ) (q 1, b,
More informationPushdown Automata. Reading: Chapter 6
Pushdown Automata Reading: Chapter 6 1 Pushdown Automata (PDA) Informally: A PDA is an NFA-ε with a infinite stack. Transitions are modified to accommodate stack operations. Questions: What is a stack?
More informationAssignment #2 COMP 3200 Spring 2012 Prof. Stucki
Assignment #2 COMP 3200 Spring 2012 Prof. Stucki 1) Construct deterministic finite automata accepting each of the following languages. In (a)-(c) the alphabet is = {0,1}. In (d)-(e) the alphabet is ASCII
More informationCSE 105 THEORY OF COMPUTATION
CSE 105 THEORY OF COMPUTATION Spring 2016 http://cseweb.ucsd.edu/classes/sp16/cse105-ab/ Today's learning goals Sipser Ch 3.3, 4.1 State and use the Church-Turing thesis. Give examples of decidable problems.
More informationFall 1999 Formal Language Theory Dr. R. Boyer. Theorem. For any context free grammar G; if there is a derivation of w 2 from the
Fall 1999 Formal Language Theory Dr. R. Boyer Week Seven: Chomsky Normal Form; Pumping Lemma 1. Universality of Leftmost Derivations. Theorem. For any context free grammar ; if there is a derivation of
More informationCSci 311, Models of Computation Chapter 4 Properties of Regular Languages
CSci 311, Models of Computation Chapter 4 Properties of Regular Languages H. Conrad Cunningham 29 December 2015 Contents Introduction................................. 1 4.1 Closure Properties of Regular
More informationPart 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
Automata & languages A primer on the Theory of Computation Laurent Vanbever www.vanbever.eu Part 4 out of 5 ETH Zürich (D-ITET) October, 12 2017 Last week, we showed the equivalence of DFA, NFA and REX
More informationECS120 Fall Discussion Notes. October 25, The midterm is on Thursday, November 2nd during class. (That is next week!)
ECS120 Fall 2006 Discussion Notes October 25, 2006 Announcements The midterm is on Thursday, November 2nd during class. (That is next week!) Homework 4 Quick Hints Problem 1 Prove that the following languages
More informationChap. 7 Properties of Context-free Languages
Chap. 7 Properties of Context-free Languages 7.1 Normal Forms for Context-free Grammars Context-free grammars A where A N, (N T). 0. Chomsky Normal Form A BC or A a except S where A, B, C N, a T. 1. Eliminating
More informationNote: In any grammar here, the meaning and usage of P (productions) is equivalent to R (rules).
Note: In any grammar here, the meaning and usage of P (productions) is equivalent to R (rules). 1a) G = ({R, S, T}, {0,1}, P, S) where P is: S R0R R R0R1R R1R0R T T 0T ε (S generates the first 0. R generates
More information1. 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,
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, v, x, y, z as per the pumping theorem. 3. Prove that
More informationPushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen
Pushdown automata Twan van Laarhoven Institute for Computing and Information Sciences Intelligent Systems Version: fall 2014 T. van Laarhoven Version: fall 2014 Formal Languages, Grammars and Automata
More informationDeterministic PDA s. Deepak D Souza. 21 October Department of Computer Science and Automation Indian Institute of Science, Bangalore.
Deterministic PDA s Deepak D Souza Department of Computer Science and Automation Indian Institute of Science, Bangalore. 21 October 2011 Outline 1 Deterministic PDA s 2 Closure properties of DCFL s 3 Complementing
More informationNotes for Comp 497 (Comp 454) Week 10 4/5/05
Notes for Comp 497 (Comp 454) Week 10 4/5/05 Today look at the last two chapters in Part II. Cohen presents some results concerning context-free languages (CFL) and regular languages (RL) also some decidability
More informationProperties of Context-Free Languages. Closure Properties Decision Properties
Properties of Context-Free Languages Closure Properties Decision Properties 1 Closure Properties of CFL s CFL s are closed under union, concatenation, and Kleene closure. Also, under reversal, homomorphisms
More information10. The GNFA method is used to show that
CSE 355 Midterm Examination 27 February 27 Last Name Sample ASU ID First Name(s) Ima Exam # Sample Regrading of Midterms If you believe that your grade has not been recorded correctly, return the entire
More informationLecture 17: Language Recognition
Lecture 17: Language Recognition Finite State Automata Deterministic and Non-Deterministic Finite Automata Regular Expressions Push-Down Automata Turing Machines Modeling Computation When attempting to
More informationLanguages, regular languages, finite automata
Notes on Computer Theory Last updated: January, 2018 Languages, regular languages, finite automata Content largely taken from Richards [1] and Sipser [2] 1 Languages An alphabet is a finite set of characters,
More information