Properties of Context-Free Languages
|
|
- Louisa Russell
- 5 years ago
- Views:
Transcription
1 Properties of Context-Free Languages Seungjin Choi Department of Computer Science and Engineering Pohang University of Science and Technology 77 Cheongam-ro, Nam-gu, Pohang 37673, Korea 1 / 31
2 Outline Simplification of CFG s: We have already done this. See Lecture 07! Pumping Lemma for CFL s: Similar to the regular case, but slightly more complex. Closure properties: Some but not all, of the closure properties of regular languages carry over to CFL s. Decision properties: Test for membership and emptiness (for instance, CYK algorithm). 2 / 31
3 Before we move on the pumping lemma... Theorem Suppose we have a parse tree according to a CNF, G = (V, T, S, P) and suppose that the yield of the tree is a terminal string w. If the length of the longest path is n, then w 2 n 1. Proof. A simple induction on n. Basis: n = 1. The length of a path in a tree is the number of edges, i.e., one less than the number of nodes. A tree with a maximum path length of 1 consists of only a root and one leaf labeled by a terminal. Thus w = 1. Since 2 n 1 = 2 0 = 1, the basis is proved. Induction: Suppose that the longest path has length n (n > 1). The root of the tree uses a production, which must be of the form A BC. No path in the subtree rooted at B and C can have length greater than n 1, since these path exclude the edge from the root to its child labeled B or C. Thus, by the IH, these two subtrees each have yields of length at most 2 n 2. The yield of entire tree is the concatenation of these two yields, so has length at most 2 n n 2 = 2 n 1. 3 / 31
4 Pumping Lemma for CFL Theorem Let L be a CFL. Then there exists a positive integer n such that if z is any string in L with z n, then we can write z = uvwxy, subject to the following conditions: 1. vwx n. That is, the middle portion is not too long. 2. vx ɛ. Since v and x are the pieces to be pumped, this condition says at least one of the strings we pump must not be empty. 3. i 0, uv i wx i y L. 4 / 31
5 Proof. Start with a CNF, G = (V, T, S, P) such that L(G) = L {ɛ}. Let G have m variables. Choose n = 2 m. Next, suppose that z L is of length at least n. Any parse tree whose longest path is of length m, must have a yield of length 2 m 1 = n 2 or less. Thus, any parse tree with yield z has a path of length at least m + 1. A 0 A 1 A 2. A k a 5 / 31
6 Since k m, there are at least m + 1 occurrences of variables A 0, A 1,..., A k on the path. As there are only m different variables in V, at least two of the last m + 1 variables on the path must be the same. Suppose A i = A j where k m i < j k. S A i = A j A j u v w x y z 6 / 31
7 If A i = A j = A, then we can construct new parse trees. S A A u v w x y 7 / 31
8 We may replace the subtree rooted at A i, which has yield vwx, by the subtree rooted at A j, which has yield w. (i = 0) S A w u y 8 / 31
9 We may replace the subtree rooted at A i by the entire subtree rooted at A i. (i = 2) S A A u v A x y v w x 9 / 31
10 What about the case where vwx n? We picked A i to be close to the bottom of the tree, k i m. Thus the longest path in the subtree rooted at A i is no longer than m + 1. By theorem, the subtree rooted at A i has a yield whose length is no greater than 2 m = n. 10 / 31
11 Examples Prove that the following languages are not context-free: 1. L = {a n b n c n n 0}; 2. L = {ww w {a, b} }. 11 / 31
12 Closure Properties of CFL The family of CFL s is closed under: union concatenation star-closure ( ) and positive closure (+) homomorphisms and inverse homomorphisms The family of CFL s is not closed under: intersection complementation difference 12 / 31
13 Substitutions We introduce an operation substitution (denoted by s( ), in which we replace each symbol in the strings of one language by an entire language. (a generalization of the homomorphism) Consider a mapping s : Σ 2, where Σ and are finite alphabets. Let w Σ where w = a 1 a 2 a n, and define and for L Σ s(a 1 a 2 a n ) = s(a 1 )s(a 2 ) s(a n ), s(l) = w L s(w). 13 / 31
14 Example: Given Σ = {0, 1}, = {a, b}, s(0) = {a n b n n 1}, s(1) = {aa, bb}. Let w = 01. Then s(w) = s(0)s(1) = {a n b n aa n 1} {a n b n+2 n 1}. Let L = {0}. Then s(l) = (s(0)) = {a n1 b n1 a n2 b n2 a n k b n k k 0, n i 1}. 14 / 31
15 Theorem (Substitution theorem) Let L be a CFL over Σ and s( ) a substitution such that s(a) is a CFL, a Σ. Then s(l) is a CFL. Proof. The essential idea is that we may take a CFG for L and replace each terminal a by the start symbol of a CFG for language s(a). The result is a single CFG that generates s(l). We start with grammars for L and for each s(a). G = (V, T, S, P), G a = (V a, T a, S a, P a ), 15 / 31
16 We then construct G for s(l), where ( 1. V = a Σ V a ) V ; G = (V, T, S, P ), 2. T = a Σ T a ; 3. P = a Σ P a plus the productions of P but with each terminal a in their bodies replaced by S a everywhere a occurs. 16 / 31
17 Now we have to show that L(G ) = s(l). (If): Let w s(l). Then x = a 1 a 2 a n in L and x i s(a i ) such that w = x 1 x 2 x n. A derivation tree in G will look like S Sa 1 Sa 2 San x 1 x 2 xn Thus we can generate S a1 S a2 S an x 1 x 2 x n = w. Thus w L(G ). in G and form there we generate 17 / 31
18 (Only if): Let w L(G ). Then the parse tree for w must again look like S Sa 1 Sa 2 San x 1 x 2 xn Now delete the dangling subtrees. Then you have yield S a1 S a2 S an, where a 1 a 2 a n L(G). Now w is also equal to s(a 1 a 2 a n ) which is in s(l). 18 / 31
19 Theorem The CFL s are closed under: (1) union; (2) concatenation; (3) star-closure ( ) and positive closure (+); (4) homomorphism. Proof. The proof is done using the substitution theorem. 1. Let L 1 and L 2 be CFL s. Let L = {1, 2} and s(1) = L 1, s(2) = L 2. Then s(l) = L 1 L Choose L = {12} and s as before. Then s(l) = L 1 L 2, which is CFL. 3. Suppose L 1 is CFL. Let L = {1}, s(1) = L 1. Then L 1 = s(l). Similar proof for Let L 1 be a CFL over Σ and h a homomorphism on Σ. Then define s by a {h(a)}. Then h(l) = s(l). 19 / 31
20 Theorem If L is a CFL, so is L R. Proof. Suppose L is generated by G = (V, T, S, P). Construct G R = (V, T, S, P R ) where P R = {A α R A α P}. Easy induction on the lengths of derivations in G and G R to show that L(G R ) = L R. 20 / 31
21 The CFL s are not closed under intersection. A simple example is as follows. Consider two CFL s L 1 and L 2 given by L 1 = {0 n 1 n 2 i n 1, i 1}, L 2 = {0 i 1 n 2 n n 1, i 1}. However, L = L 1 L 2 = {0 n 1 n 2 n n 1} is not CFL. (prove it) See Example 7.26 in page 291! 21 / 31
22 Theorem If L is a CFL and R is a RL, then L R is a CFL. Proof. Let L be accepted by PDA M P = (Q P, Σ, Γ, δ P, q P, Z 0, F P ) by final state and let R be accepted by DFA Construct a PDA for L R as shown in the RHS. M D = (Q D, Σ, δ D, q D, F D ). 22 / 31
23 Formally, define M P = (Q P Q D, Σ, Γ, δ, (q P, q D ), Z 0, F P F D ), where δ((q, p), a, X ) = {((r, δd(p, a)), γ) (r, γ) δ P (q, a, X )}. One can easily prove by an induction, both for M P and for M P that (q P, w, Z 0 ) (q, ɛ, γ) in M P, if and only if ((q P, a D ), w, Z 0 ) ((q, δ (p D, w)), ɛ, γ) in M P. 23 / 31
24 Theorem Let L, L 1, L 2 be CFL s and R be regular. Then 1. L R is a CFL; 2. L is not necessarily CFL; 3. L 1 L 2 is not necessarily CFL. Theorem Let L be a CFL and h a homomorphism. Then h 1 (L) is a CFL. 24 / 31
25 Testing Membership: CYK Algorithm Testing membership: Decide membership of a string w in a CFL L. A naive way to test membership, takes time which is exponential in w. We discuss an efficient technique based on the idea of dynamic programming. CYK algorithm: Named after J. Cocke, D. Younger, and T. Kasami. 25 / 31
26 Dynamic Programming vs Divide-and-Conquer Divide-and-conquer Divide-and-conquer works best when all sub-problems are independent. Divide-and conquer is best suited for the case when no overlapping subproblems are encountered. Dynamic programming Dynamic programming is a method for solving complex problems by breaking them down into simpler sub-problems. It is applicable to problems exhibiting the properties of overlapping sub-problems which are only slightly smaller and optimal sub-structure. Dynamic programming is needed when sub-problems are dependent. Dynamic programming solves the sub-problem only once and then stores it in table. Dynamic programming solves the sub-problems bottom up. The problem cant be solved until we find all solutions of sub-problems. The solution comes up when the whole problem appears.. 26 / 31
27 CYK Algorithm Starts with a CNF grammar G = (V, T, S, P). Input: w = a 1 a 2 a n. Construct a triangular table where X ij contains all variables A such that A a i a i+1 a j. 27 / 31
28 To fill the table we work row-by-row, upwards. The first row is computed in the basis, the subsequent ones in the induction. Basis: X ii = {A A a i G}. Induction: Compute X ij which is in row j i + 1. Any derivation A a i a i+1 a j must start with some step A BC. Then B a i a i+1 a k for some k < j and C a k+1 a k+2 a j. We find variables B and C and integer k such that: 1. i k < j. 2. B is in X ik. 3. C is in X k+1 j. 4. A BC is a production of G. 28 / 31
29 Example: See Ex 7.34 in page 306. A CNF grammar G has the following productions: S AB BC, A BA a, B CC b, C AB a. 29 / 31
30 Consider which variables have a production body a or b, leading to X 11 = X 44 = {B} and X 22 = X 33 = X 55 = {A, C}. Compute X 12 : In order for a variable to generate ba it must have a body whose first variable is in X 11 = {B} and whose second variable is in X 22 = {A, C}, leading to variables containing a body BA or BC. Such variables are {S,A}. Compute X 24 : Consider all bodies in X 22 X 34 X 23 X 44. The set of strings is {A, C}{S, C} {B}{B} = {AS, AC, CS, CC, BB}. Only CC is a body and its head is B. Thus, X 24 = {B} 30 / 31
31 Theorem The run time of the CYK algorithm is O(n 3 ). A string w is in L(G) if and only if S is in X 1n. 31 / 31
Non-context-Free Languages. CS215, Lecture 5 c
Non-context-Free Languages CS215, Lecture 5 c 2007 1 The Pumping Lemma Theorem. (Pumping Lemma) Let be context-free. There exists a positive integer divided into five pieces, Proof for for each, and..
More informationThis lecture covers Chapter 7 of HMU: Properties of CFLs
This lecture covers Chapter 7 of HMU: Properties of CFLs Chomsky Normal Form Pumping Lemma for CFs Closure Properties of CFLs Decision Properties of CFLs Additional Reading: Chapter 7 of HMU. Chomsky Normal
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 informationFinite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018
Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Lecture 14 Ana Bove May 14th 2018 Recap: Context-free Grammars Simplification of grammars: Elimination of ǫ-productions; Elimination of
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 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 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 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 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 informationProperties of Context-free Languages. Reading: Chapter 7
Properties of Context-free Languages Reading: Chapter 7 1 Topics 1) Simplifying CFGs, Normal forms 2) Pumping lemma for CFLs 3) Closure and decision properties of CFLs 2 How to simplify CFGs? 3 Three ways
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 informationContext-Free Grammars and Languages
Context-Free Grammars and Languages Seungjin Choi Department of Computer Science and Engineering Pohang University of Science and Technology 77 Cheongam-ro, Nam-gu, Pohang 37673, Korea seungjin@postech.ac.kr
More informationCS20a: summary (Oct 24, 2002)
CS20a: summary (Oct 24, 2002) Context-free languages Grammars G = (V, T, P, S) Pushdown automata N-PDA = CFG D-PDA < CFG Today What languages are context-free? Pumping lemma (similar to pumping lemma for
More informationBefore We Start. The Pumping Lemma. Languages. Context Free Languages. Plan for today. Now our picture looks like. Any questions?
Before We Start The Pumping Lemma Any questions? The Lemma & Decision/ Languages Future Exam Question What is a language? What is a class of languages? Context Free Languages Context Free Languages(CFL)
More informationFoundations of Informatics: a Bridging Course
Foundations of Informatics: a Bridging Course Week 3: Formal Languages and Semantics Thomas Noll Lehrstuhl für Informatik 2 RWTH Aachen University noll@cs.rwth-aachen.de http://www.b-it-center.de/wob/en/view/class211_id948.html
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 informationContext-Free Grammars: Normal Forms
Context-Free Grammars: Normal Forms Seungjin Choi Department of Computer Science and Engineering Pohang University of Science and Technology 77 Cheongam-ro, Nam-gu, Pohang 37673, Korea seungjin@postech.ac.kr
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 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 informationComputational Models - Lecture 5 1
Computational Models - Lecture 5 1 Handout Mode Iftach Haitner. Tel Aviv University. November 28, 2016 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice Herlihy, Brown University.
More informationOgden s Lemma. and Formal Languages. Automata Theory CS 573. The proof is similar but more fussy. than the proof of the PL4CFL.
CS 573 Automata Theory and Formal Languages Professor Leslie Lander Lecture # 24 December 4, 2000 Ogden s Lemma (6.2) Let L be a CFL, then there is a constant n such that if z is a word in L with z > n
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 informationIntroduction to Automata
Introduction to Automata Seungjin Choi Department of Computer Science and Engineering Pohang University of Science and Technology 77 Cheongam-ro, Nam-gu, Pohang 37673, Korea seungjin@postech.ac.kr 1 /
More informationContext-Free Languages
CS:4330 Theory of Computation Spring 2018 Context-Free Languages Non-Context-Free Languages Haniel Barbosa Readings for this lecture Chapter 2 of [Sipser 1996], 3rd edition. Section 2.3. Proving context-freeness
More informationCPS 220 Theory of Computation
CPS 22 Theory of Computation Review - Regular Languages RL - a simple class of languages that can be represented in two ways: 1 Machine description: Finite Automata are machines with a finite number of
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 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 informationMiscellaneous. Closure Properties Decision Properties
Miscellaneous Closure Properties Decision Properties 1 Closure Properties of CFL s CFL s are closed under union, concatenation, and Kleene closure. Also, under reversal, homomorphisms and inverse homomorphisms.
More informationComputational Models - Lecture 5 1
Computational Models - Lecture 5 1 Handout Mode Iftach Haitner and Yishay Mansour. Tel Aviv University. April 10/22, 2013 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice
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 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 informationCS375: Logic and Theory of Computing
CS375: Logic and Theory of Computing Fuhua (Frank) Cheng Department of Computer Science University of Kentucky 1 Table of Contents: Week 1: Preliminaries (set algebra, relations, functions) (read Chapters
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 informationEinführung in die Computerlinguistik
Einführung in die Computerlinguistik Context-Free Grammars formal properties Laura Kallmeyer Heinrich-Heine-Universität Düsseldorf Summer 2018 1 / 20 Normal forms (1) Hopcroft and Ullman (1979) A normal
More informationNotes for Comp 497 (454) Week 10
Notes for Comp 497 (454) Week 10 Today we look at the last two chapters in Part II. Cohen presents some results concerning the two categories of language we have seen so far: Regular languages (RL). Context-free
More informationComputational Models - Lecture 4 1
Computational Models - Lecture 4 1 Handout Mode Iftach Haitner and Yishay Mansour. Tel Aviv University. April 3/8, 2013 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice
More informationEven More on Dynamic Programming
Algorithms & Models of Computation CS/ECE 374, Fall 2017 Even More on Dynamic Programming Lecture 15 Thursday, October 19, 2017 Sariel Har-Peled (UIUC) CS374 1 Fall 2017 1 / 26 Part I Longest Common Subsequence
More informationHarvard CS 121 and CSCI E-207 Lecture 12: General Context-Free Recognition
Harvard CS 121 and CSCI E-207 Lecture 12: General Context-Free Recognition Salil Vadhan October 11, 2012 Reading: Sipser, Section 2.3 and Section 2.1 (material on Chomsky Normal Form). Pumping Lemma for
More informationCSCI Compiler Construction
CSCI 742 - Compiler Construction Lecture 12 Cocke-Younger-Kasami (CYK) Algorithm Instructor: Hossein Hojjat February 20, 2017 Recap: Chomsky Normal Form (CNF) A CFG is in Chomsky Normal Form if each rule
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 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 informationChapter 16: Non-Context-Free Languages
Chapter 16: Non-Context-Free Languages Peter Cappello Department of Computer Science University of California, Santa Barbara Santa Barbara, CA 93106 cappello@cs.ucsb.edu Please read the corresponding chapter
More informationTAFL 1 (ECS-403) Unit- III. 3.1 Definition of CFG (Context Free Grammar) and problems. 3.2 Derivation. 3.3 Ambiguity in Grammar
TAFL 1 (ECS-403) Unit- III 3.1 Definition of CFG (Context Free Grammar) and problems 3.2 Derivation 3.3 Ambiguity in Grammar 3.3.1 Inherent Ambiguity 3.3.2 Ambiguous to Unambiguous CFG 3.4 Simplification
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 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 informationContext Free Languages and Grammars
Algorithms & Models of Computation CS/ECE 374, Fall 2017 Context Free Languages and Grammars Lecture 7 Tuesday, September 19, 2017 Sariel Har-Peled (UIUC) CS374 1 Fall 2017 1 / 36 What stack got to do
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 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 information6.1 The Pumping Lemma for CFLs 6.2 Intersections and Complements of CFLs
CSC4510/6510 AUTOMATA 6.1 The Pumping Lemma for CFLs 6.2 Intersections and Complements of CFLs The Pumping Lemma for Context Free Languages One way to prove AnBn is not regular is to use the pumping lemma
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 informationComment: The induction is always on some parameter, and the basis case is always an integer or set of integers.
1. For each of the following statements indicate whether it is true or false. For the false ones (if any), provide a counter example. For the true ones (if any) give a proof outline. (a) Union of two non-regular
More informationContext Free Language Properties
Context Free Language Properties Knowing that the context free languages are exactly those sets accepted by nondeterministic pushdown automata provides us a bit of information about them. We know that
More informationCS311 Computational Structures More about PDAs & Context-Free Languages. Lecture 9. Andrew P. Black Andrew Tolmach
CS311 Computational Structures More about PDAs & Context-Free Languages Lecture 9 Andrew P. Black Andrew Tolmach 1 Three important results 1. Any CFG can be simulated by a PDA 2. Any PDA can be simulated
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 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 informationTheory of Computation 8 Deterministic Membership Testing
Theory of Computation 8 Deterministic Membership Testing Frank Stephan Department of Computer Science Department of Mathematics National University of Singapore fstephan@comp.nus.edu.sg Theory of Computation
More informationContext-Free Grammars (and Languages) Lecture 7
Context-Free Grammars (and Languages) Lecture 7 1 Today Beyond regular expressions: Context-Free Grammars (CFGs) What is a CFG? What is the language associated with a CFG? Creating CFGs. Reasoning about
More informationCOMP-330 Theory of Computation. Fall Prof. Claude Crépeau. Lec. 10 : Context-Free Grammars
COMP-330 Theory of Computation Fall 2017 -- Prof. Claude Crépeau Lec. 10 : Context-Free Grammars COMP 330 Fall 2017: Lectures Schedule 1-2. Introduction 1.5. Some basic mathematics 2-3. Deterministic finite
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 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 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 informationConcordia University Department of Computer Science & Software Engineering
Concordia University Department of Computer Science & Software Engineering COMP 335/4 Theoretical Computer Science Winter 2015 Assignment 3 1. In each case, what language is generated by CFG s below. Justify
More informationCS5371 Theory of Computation. Lecture 7: Automata Theory V (CFG, CFL, CNF)
CS5371 Theory of Computation Lecture 7: Automata Theory V (CFG, CFL, CNF) Announcement Homework 2 will be given soon (before Tue) Due date: Oct 31 (Tue), before class Midterm: Nov 3, (Fri), first hour
More informationPushdown 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 informationComputational Models - Lecture 4 1
Computational Models - Lecture 4 1 Handout Mode Iftach Haitner. Tel Aviv University. November 21, 2016 1 Based on frames by Benny Chor, Tel Aviv University, modifying frames by Maurice Herlihy, Brown University.
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 informationAutomata and Computability. Solutions to Exercises
Automata and Computability Solutions to Exercises Spring 27 Alexis Maciel Department of Computer Science Clarkson University Copyright c 27 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata
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 2 Design a PDA and a CFG for a given language Give informal description for a PDA,
More informationCS154 Final Examination
CS154 Final Examination June 7, 2010, 7-10PM Directions: CS154 students: answer all 13 questions on this paper. Those taking CS154N should answer only questions 8-13. The total number of points on this
More informationLecture 7 Properties of regular languages
Lecture 7 Properties of regular languages COT 4420 Theory of Computation Section 4.1 Closure properties of regular languages If L 1 and L 2 are regular languages, then we prove that: Union: L 1 L 2 Concatenation:
More informationMA/CSSE 474 Theory of Computation
MA/CSSE 474 Theory of Computation CFL Hierarchy CFL Decision Problems Your Questions? Previous class days' material Reading Assignments HW 12 or 13 problems Anything else I have included some slides online
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 informationFORMAL LANGUAGES, AUTOMATA AND COMPUTATION
FORMAL LANGUAGES, AUTOMATA AND COMPUTATION DECIDABILITY ( LECTURE 15) SLIDES FOR 15-453 SPRING 2011 1 / 34 TURING MACHINES-SYNOPSIS The most general model of computation Computations of a TM are described
More informationAutomata and Computability. Solutions to Exercises
Automata and Computability Solutions to Exercises Fall 28 Alexis Maciel Department of Computer Science Clarkson University Copyright c 28 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata
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 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 informationCS481F01 Solutions 6 PDAS
CS481F01 Solutions 6 PDAS A. Demers 2 November 2001 1. Give a NPDAs that recognize the following languages: (a) The set of all strings in {0, 1} that contain twice as many 1s as 0s. (answer a) We build
More informationThe Pumping Lemma and Closure Properties
The Pumping Lemma and Closure Properties Mridul Aanjaneya Stanford University July 5, 2012 Mridul Aanjaneya Automata Theory 1/ 27 Tentative Schedule HW #1: Out (07/03), Due (07/11) HW #2: Out (07/10),
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 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 Formal Languages TMV026/DIT321 LP Useful, Useless, Generating and Reachable Symbols
Finite Automata and Formal Languages TMV026/DIT321 LP4 2012 Lecture 13 Ana Bove May 7th 2012 Overview of today s lecture: Normal Forms for Context-Free Languages Pumping Lemma for Context-Free Languages
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 informationV Honors Theory of Computation
V22.0453-001 Honors Theory of Computation Problem Set 3 Solutions Problem 1 Solution: The class of languages recognized by these machines is the exactly the class of regular languages, thus this TM variant
More information60-354, Theory of Computation Fall Asish Mukhopadhyay School of Computer Science University of Windsor
60-354, Theory of Computation Fall 2013 Asish Mukhopadhyay School of Computer Science University of Windsor Pushdown Automata (PDA) PDA = ε-nfa + stack Acceptance ε-nfa enters a final state or Stack is
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 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 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 informationAC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013
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
More informationEinführung in die Computerlinguistik Kontextfreie Grammatiken - Formale Eigenschaften
Normal forms (1) Einführung in die Computerlinguistik Kontextfreie Grammatiken - Formale Eigenschaften Laura Heinrich-Heine-Universität Düsseldorf Sommersemester 2013 normal form of a grammar formalism
More informationGrammars and Context Free Languages
Grammars and Context Free Languages H. Geuvers and A. Kissinger Institute for Computing and Information Sciences Version: fall 2015 H. Geuvers & A. Kissinger Version: fall 2015 Talen en Automaten 1 / 23
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 informationParsing. Context-Free Grammars (CFG) Laura Kallmeyer. Winter 2017/18. Heinrich-Heine-Universität Düsseldorf 1 / 26
Parsing Context-Free Grammars (CFG) Laura Kallmeyer Heinrich-Heine-Universität Düsseldorf Winter 2017/18 1 / 26 Table of contents 1 Context-Free Grammars 2 Simplifying CFGs Removing useless symbols Eliminating
More informationContext-Free Grammars and Languages. Reading: Chapter 5
Context-Free Grammars and Languages Reading: Chapter 5 1 Context-Free Languages The class of context-free languages generalizes the class of regular languages, i.e., every regular language is a context-free
More informationGrammars and Context Free Languages
Grammars and Context Free Languages H. Geuvers and J. Rot Institute for Computing and Information Sciences Version: fall 2016 H. Geuvers & J. Rot Version: fall 2016 Talen en Automaten 1 / 24 Outline Grammars
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 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 informationTheory Bridge Exam Example Questions
Theory Bridge Exam Example Questions Annotated version with some (sometimes rather sketchy) answers and notes. This is a collection of sample theory bridge exam questions. This is just to get some idea
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 informationTheory Of Computation UNIT-II
Regular Expressions and Context Free Grammars: Regular expression formalism- equivalence with finite automata-regular sets and closure properties- pumping lemma for regular languages- decision algorithms
More informationContext Free Languages: Decidability of a CFL
Theorem 14.1 Context Free Languages: Decidability of a CFL Statement: Given a CFL L and string w, there is a decision procedure that determines whether w L. Proof: By construction. 1. Proof using a grammar
More information