The View Over The Horizon
|
|
- Frank Jennings
- 5 years ago
- Views:
Transcription
1 The View Over The Horizon enumerable decidable context free regular
2 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. Each rule has the form: symbol string. The left-hand symbol is a variable (usually upper-case). A string consists of variables and terminals. One variable is the start variable.
3 Rules for Generating Strings Write down the start variable (lhs of top rule). Pick a variable written down in current string and a derivation that starts with that variable. Replace that variable with right-hand side of that derivation. Repeat until no variables remain. Return final string (concatenation of terminals). Process is inherently non deterministic.
4 Example Grammar G 1 : A 0A1 A B B # Derivation with G 1 : A 0A1 00A11 000A B #111
5 AParseTree A A A B # Question: What strings can be generated in this way from the grammar G 1? Answer: Exactly those of the form 0 n #1 n (n 0).
6 Context-Free Languages The language generated in this way is called the language of the grammar. For example, L(G 1 ) is {0 n #1 n n 0}. Any language generated by a context-free grammar is called a context-free language.
7 AUsefulAbbreviation Rules with same variable on left hand side A 0A1 A B are written as: A 0A1 B
8 English-like Sentences AgrammarG 2 to describe a few English sentences: < SENTENCE > < NOUN-PHRASE >< VERB > < NOUN-PHRASE > < ARTICLE >< NOUN > < NOUN > boy girl flower < ARTICLE > a the < VERB > touches likes sees
9 Deriving English-like Sentences A specific derivation in G 2 : < SENTENCE > < NOUN-PHRASE >< VERB > < ARTICLE >< NOUN >< VERB > a < NOUN >< VERB > aboy < VERB > aboysees More strings generated by G 2 : aflowersees the girl touches
10 Derivation and Parse Tree < SENTENCE > < NOUN-PHRASE >< VERB > < ARTICLE >< NOUN >< VERB > a < NOUN >< VERB > aboy < VERB > aboysees SENTENCE NOUN-PHRASE VERB ARTICLE NOUN a boy sees
11 Formal Definitions A context-free grammar is a 4-tuple (V,Σ,R,S) where V is a finite set of variables, Σ is a finite set of terminals, R is a finite set of rules: each rule is a variable and a finite string of variables and terminals. S is the start symbol.
12 Formal Definitions If u and v are strings of variables and terminals, and A w is a rule of the grammar, then we say uav yields uwv, written uav uwv. We write u v if u = v or u u 1... u k v. for some sequence u 1,u 2,...,u k. Definition: { Thelanguage } of the grammar is w Σ S w.
13 Example Consider G 4 =(V,{a, b},r,s). R (Rules): S asb SS ε. Some words in the language: aabb, aababb. Q.: Butwhatis this language? Hint: Think of parentheses.
14 Arithmetic Example Consider (V,Σ,R,E) where V = {E,T,F} Σ = {a, +,, (, )} Rules: E E + T T T T F F F (E) a Strings generated by the grammer: a + a a and (a + a) a. What is the language of this grammer? Hint: arithmetic expressions. E = expression, T = term, F = factor.
15 Parse Tree for a + a a E E + T T T T F F F (E) a E E T T T F F F a + a X a
16 Parse Tree for (a + a) a E T E E + T T T T F F F (E) a T F E E T T F F F ( a + a ) X a
17 Designing Context-Free Grammars No recipe in general, but few rules-of-thumb If CFG is the union of several CFGs, rename variables (not terminals) so they are disjoint, and add new rule S S 1 S 2... S i. To construct CFG for a regular language, follow a DFA for the language. For initial state q 0,makeR 0 the start variable. For state transition δ(q i,a)=q j add rule R i ar j to grammar. For each final state q f, add rule R f ε to grammar. For languages with linked substrings (like {0 n #1 n n 0} ), a rule of form R urv may be helpful, forcing desired relation between substrings.
18 Closure Properties Regular languages are closed under union concatenation star Context-Free Languages are closed under union : S S 1 S 2 concatenation S S 1 S 2 star S ε SS
19 More Closure Properties Regular languages are also closed under complement (reverse accept/non-accept states of DFA) ) intersection (L 1 L 2 = L 1 L 2. What about complement and intersection of context-free languages? Not clear...
20 Chomsky Normal Form A simplified, canonical form of context free grammers. Every rule has the form A BC A a S ε where S is the start symbol, A, B and C are any variable, except B and C not the start symbol, and A can be the start symbol.
21 CFN: Theorem Theorem: Any context-free language is generated by a context-free grammar in Chomsky normal form. Basic idea: Add new start symbol S 0. Eliminate all ε rules of the form A ε. Eliminate all unit rules of the form A B. Patch up rules so that grammar generates the same language. Convert remaining long rules to proper form.
22 Proof Add new start symbol S 0 and rule S 0 S. Guarantees that new start symbol does not appear on right-hand-side of a rule.
23 Proof Eliminating ε rules. Repeat: remove some A ε. for each R uav, add rule R uv. and so on: for R uavaw add R uvaw, R uavw, and R uvw. for R A add R ε, except if R ε has already been removed. until all ε-rules not involving the original start variable have been removed.
24 Proof Eliminate unit rules. Repeat: remove some A B. for each B u, add rule A u, unless this is previously removed unit rule. (u is a string of variables and terminals.) until all unit rules have been removed.
25 Proof Finally, convert long rules. To replace each A u 1 u 2...u k (for k 3), introduce new non-terminals N 1,N 2,...,N k 1 and rules A u 1 N 1 N 1 u 2 N 2. N k 3 u k 2 N k 2 N k 2 u k 1 u k
26 Conversion Example Initial Grammar: S ASA ab A B S B b ε (1) Add new start state: S 0 S S ASA ab A B S B b ε
27 Conversion Example (2) S 0 S S ASA ab A B S B b ε (2) Remove ε-rule B ε: S 0 S S ASA ab a A B S ε B b ε
28 Conversion Example (3) S 0 S S ASA ab a A B S ε B b (3) Remove ε-rule A ε: S 0 S S ASA ab a AS SA S A B S ε B b
29 Conversion Example (4) S 0 S S ASA ab a AS SA S A B S B b (4) Remove unit rule S S S 0 S S ASA ab a AS SA S A B S B b
30 Conversion Example (5) S 0 S S ASA ab a AS SA A B S B b (5) Remove unit rule S 0 S: S 0 S ASA ab a AS SA S ASA ab a AS SA A B S B b
31 Conversion Example (6) S 0 ASA ab a AS SA S ASA ab a AS SA A B S B b (6) Remove unit rule A B: S 0 ASA ab a AS SA S ASA ab a AS SA A B S b B b
32 Conversion Example (7) S 0 ASA ab a AS SA S ASA ab a AS SA A S b B b Remove unit rule A S: S 0 ASA ab a AS SA S ASA ab a AS SA A S b ASA ab a AS SA B b
33 Conversion Example (8) S 0 ASA ab a AS SA S ASA ab a AS SA A b ASA ab a AS SA B b (8) Final simplification treat long rules: S 0 AA 1 UB a SA AS S AA 1 UB a SA AS A b AA 1 UB a SA AS A 1 SA U a B b
34 Example 2 Consider G 5 =(V,{a, b},r,s). R (Rules): S asb bsa ε. Some words in the language: abba, aabaabaa. Q.: Butwhatis this language? L(G 5 )={ww R w {a, b} }
35 Example 3 Consider G 6 =(V,{a, b},r,s). R (Rules): S ab ba ε. A a as baa. B b bs abb. Some words in the language: aababb, baabba. Q.: But what is this language? L(G 6 )={w {a, b} # a (w) =# b (w)}
36 Example L(G 6 )={w {a, b} # a (w) =# b (w)} What do we need to show?! (1) If w generated by G 6 then # a (w) =# b (w). (2) If # a (w) =# b (w) then w generated by G 6. Claim: If S α then # a (α)+# A (α) =# b (α)+# B (α). Claim: For any w let k =# a (w) # b (w). Then: (i) if k =0then S ws, (ii) if k>0then S wa k, (iii) if k<0then S wb k Are we done?!
37 Non-Context-Free Languages The pumping lemma for finite automata and Myhill-Nerode theorem are our tools for showing that languages are not regular. We will now show a similar pumping lemma for context-free languages. It is slightly more complicated...
38 Pumping Lemma for CFL Also known as the uvxyz Theorem. Theorem: If A is a CFL, there is an l (critical length), such that if s A and s l, thens = uvxyz where for every i 0, uv i xy i z A vy > 0, (non-triviality) vxy l.
39 Basic Intuition Let A be a CFL and G its CFG. Let s be a very long string in A. Then s must have a tall parse tree. And some root-to-leaf path must repeat a symbol. ahmmm,... why is that so? T R R u v x y z
40 Proof let G be a CFG for CFL A. let b be the max number of symbols in right-hand-side of any rule. no node in parse tree has >bchildren. at depth d, canhaveatmostb d leaves. let V be the number of variables in G. set l = b V +2.
41 Proof (2) let s be a string where s l let T be parse tree for s with fewest nodes T has height V +2 some path in T has length V +2 that path repeats a variable R
42 Proof (3) Split s = uvxyz T R R u v x y z each occurrence of R produces a string upper produces string vxy lower produces string x
43 Proof Replacing smaller by larger yields uv i xy i z,fori>0. T R R u v Rx y z
44 Proof (4) Replacing larger by smaller yields uxz. T R x u z Together, they establish: for all i 0, uv i xy i z A
45 Proof (5) Next condition is: vy > 0 (out of uvxyz) If v and y are both ε, then T R x u z is a parse tree for s with fewer nodes than T, contradiction.
46 Proof (6) Final condition is vxy l: T R R V +2 u v x y z b V +2 the upper occurrence of R generates vxy. can choose symbols such that both occurrences of R lie in bottom V +1variables on path. subtree where R generates vxy is V +2high. strings by subtree at most b V +2 = l long.
47 Non CFL Example Theorem: B = {a n b n c n } is not a CFL. Proof: By contradiction. Let l be the critical length. Consider s = a l b l c l. If s = uvxyz, neither v nor y can contain both a s and b s, or both b s and c s, because otherwise uv 2 xy 2 z would have out-of-order symbols. But if v and y contain only one letter, then uv 2 xy 2 z has an imbalance!
48 Non CFL Example (2) The language C = { a i b j c k 0 i j k } is not context-free. Let l be the critical length, and s = a l b l c l. Let s = uvxyz neither v nor y contains two distinct symbols, because otherwise uv 2 xy 2 z would have out-of-order symbols. vxy cannot be all the same letter (why?) vxy l, so either v contains only a s and y contains only b s, but then uv 2 xy 2 z has too few c s. v contains only b s and y contains only c s. but then uv 0 xy 0 z has too many a s.
49 Non CFL Example (3) The language D = { ww w {0, 1} } is not context-free. Let s =0 l 1 l 0 l 1 l As before, suppose s = uvxyz. Recall that vxy l. if vxy is in the first half of s, uv 2 xy 2 z moves a 1 into the first position in second half. if vxy is in the second half, uv 2 xy 2 z moves a 0 into the last position in first half. if vxy straddles the midpoint, then pumping down to uxz yields 0 l 1 i 0 j 1 l where i and j cannot both be l. Note that D = { ww R w {0, 1} } is CFL.
50 CFL Closure Properties: Example Is L = {(0 1 2) : #of0 s = # of 1 s = # of 2 s } context free?
51 CFL Closure Properties L {(0 1 2) : # 0 s = # 1 s = # 2 s } Is L context free? L ={0 n 1 n 2 n : n>0} which is not context free. Context free languages intersected with a regular languages are context free is regular. So L is not a context free language! This could also be established using pumping lemma, but proof above is much more elegant.
52 More CFL Closure Properties Assignments Homomorphism Inverse Homomorphism
53 Algorithmic Questions for NFAs Q.: GivenanNFA,N, andastrings, iss L(N)? Answer: ConstructtheDFAequivalenttoN and run it on w. Q.: IsL(N) =? Answer: This is a reachability question in graphs: Is there a path in the states graph of N from the start state to some accepting state. There are simple, efficient algorithms for this task.
54 More Algorithmic Questions for NFAs Q.: IsL(N) =Σ? Answer: CheckifL(N) =. Q.: GivenN 1 and N 2,isL(N 1 ) L(N 2 )? Answer: CheckifL(N 2 ) L(N 1 )=. Q.: GivenN 1 and N 2,isL(N 1 )=L(N 2 )? Answer: CheckifL(N 1 ) L(N 2 ) and L(N 2 ) L(N 1 ). In the future, we will see that for stronger models of computations, many of these problems cannot be solved by any algorithm.
55 Algorithmic Questions Regarding CFGs Given a CFG, G, and a string w, doesg generate w? Initial Idea: Design an algorithm that tries all derivations. Problem: If G does not generate w, we ll never stop.
56 Algorithmic Questions for CFGs (2) Lemma: If G is in Chomsky normal form, w = n, andw is generated by G, thenw has a derivation of length 2n 1 or less. Algorithm s idea: First, convert G to Chomsky normal form. Now need only consider a finite number of derivations those of length 2n 1 or less.
57 Algorithmic Questions for CFGs: membership Build a function derive(a, x) that returns TRUE if A x PROCEDURE derive(a, x). If x =1then if A x R return TRUE, otherwise return FALSE. For each A BC and each partition x = x 1 x 2, Call derive(b,x 1 ) and derive(c, x 2 ). If both return true, exit and return TRUE. Return FALSE. Test membership by calling derive(s, w). Why did we need CNF?!
58 Emptiness of CFGs Given a CFG, G, is L(G) =? In other words, is there any string w, suchthatg generate w? Theorem: There is an algorithm that solves this problem (and always halts). Possible approaches for a proof: Bad Idea: We know how to test whether w L(G) for any string w, so just try it for each w. (criticize this...) Better Idea: Can the start variable generate a string of terminals? Even Better Idea: Can a particular variable generate a string of terminals?
59 Removing redundant variables and terminals of a CFG 1. Mark all terminal symbols in G. 2. Repeat until no new variable become marked: Mark any A where A U 1 U 2...U k and all U i have already been marked. 4. Remove all unmarked variables, and any rule they appear in. 5. If S is removed, then L(G) =. 6. Remove any variable A not reachable from S. 7. Remove any terminal which does not appear in some rule.
60 CFG Emptiness (2) Algorithm: On input G (a CFG), 1. Remove redundant variables and terminals, get G. 2. L(G )= iff S is removed
61 Finiteness of CFGs Given a CFG, G, is L(G) finite? 1. Remove redundant variables and terminals. 2. Create a graph where nodes are variables and directed edges are derivations. 3. L(G) is infinite iff the graph has a cycle.
62 CFGs Fullness Given a CFG, G, is L(G) =Σ? We just saw an algorithm to determine, given a CFG, G, if L(G) = L(G) =Σ iff L(G) =. Why not modify the algorithm so it determines emptiness of the complement? Unfortunately, CFGs are not closed under complement. Fact: There is no algorithm to solve this problem. We are not prepared to prove this remarkable fact (yet).
63 When Are Two CFGs equivalent? Given two CFGs, G, H, is L(G) =L(H)? Hey, we did this already for equivalence of DFAs! We constructed C from A and B: ( ) L(C) = L(A) L(B) and tested whether L(C) is empty. ( ) L(A) L(B).
64 When Are Two CFGs equivalent? This approach was fine for DFAs, but not for CFLs! The class of context-free languages is not closed under complementation or intersection. Fact: There is no algorithm to solve this problem. We are not prepared to prove this remarkable fact (yet).
65 Computations A computation of a Turing machine is a sequence of configurations beginning with an initial configuration and ending with a halting configuration. Computations are (primitive) recursive.
66 Non-computations The non-computations of a Turing machine M with input x can be presented as a context-free language L(G), which include sequences without an initial state sequences without a final state configurations with more than one state adjacent configurations that are wrong etc.
67 Fullness Problem: Full(G) = [L(G)=Σ*] Reduction: Halt Full halt(m,x) = Full(G(M,x)) So fullness of CFG is undecidable
68 Context-Sensitive Grammars A context-sensitive grammar has production rules of the form uaw uvw where u,v,w are strings of terminal symbols.
69 Arbitrary Grammars An arbitrary grammar has production rules of the form u v where u and v are strings of terminal symbols and variables (non-terminals), and u is non-empty. (Alternatively, one can require that u have exactly one variable.)
70 Arbitrary Grammars Turing machines can be simulated by an arbitrary grammar. For normal computations contextsensitive grammars suffice.
71 Language Classes In general, if a class C of recursive languages is recursively enumerable (e.g. regular, context-free), then there is a recursive language not in C. Proof by diagonalization.
72 Arbitrary Grammar for TMs Terminals: Tape symbols plus $, Variables: States Q i, plus A j for each tape symbol a j, plus S,B,C Three stages: 1. S => => w$q 0 w$ (initial state q 0 ) 2. Q 0 w => => uq f v (final state q f ) 3. $uq f v$ => => ε
73 Stage 1 S CB B $ B a j A j B for each a j A j a k a k A j A j a j Ca k a k C C $Q 0
74 Stage 2 Q i a j a k Q l for each right move Q i $ a k Q l $ a j =blank a m Q i a j Q l a m a k for each left move a m Q i $ Q l a m a k $ a j =blank
75 Stage 3 Q f a j Q f a m Q f Q f $Q f $ ε
76 Language Classes In general, if a class C of recursive languages is recursively enumerable (e.g. regular, contextfree), then there is a recursive language not in C. Proof by diagonalization. Moral: One cannot define a set of grammars to exactly capture the recursive languages.
77 A Short Summary Regular Languages Finite Automata. Context Free Languages Push Down Automata. Closure properties of regular languages and of CFLs. Most algorithmic problems for finite automata are solvable. Some algorithmic problems for finite automata are not solvable. Pumping lemmata for both classes of languages. There are additional languages out there.
Computational 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 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 informationComputational Models - Lecture 3
Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 1 Computational Models - Lecture 3 Equivalence of regular expressions and regular languages (lukewarm leftover
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 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 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 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 informationWhat we have done so far
What we have done so far DFAs and regular languages NFAs and their equivalence to DFAs Regular expressions. Regular expressions capture exactly regular languages: Construct a NFA from a regular expression.
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 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 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 informationCISC 4090 Theory of Computation
CISC 4090 Theory of Computation Context-Free Languages and Push Down Automata Professor Daniel Leeds dleeds@fordham.edu JMH 332 Languages: Regular and Beyond Regular: a b c b d e a Not-regular: c n bd
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 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 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 informationComputational Models: Class 5
Computational Models: Class 5 Benny Chor School of Computer Science Tel Aviv University March 27, 2019 Based on slides by Maurice Herlihy, Brown University, and modifications by Iftach Haitner and Yishay
More informationTheory of Computation (II) Yijia Chen Fudan University
Theory of Computation (II) Yijia Chen Fudan University Review A language L is a subset of strings over an alphabet Σ. Our goal is to identify those languages that can be recognized by one of the simplest
More informationComputational Models: Class 3
Computational Models: Class 3 Benny Chor School of Computer Science Tel Aviv University November 2, 2015 Based on slides by Maurice Herlihy, Brown University, and modifications by Iftach Haitner and Yishay
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 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 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 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 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 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, 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 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 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 informationDecidability (What, stuff is unsolvable?)
University of Georgia Fall 2014 Outline Decidability Decidable Problems for Regular Languages Decidable Problems for Context Free Languages The Halting Problem Countable and Uncountable Sets Diagonalization
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 informationCISC 4090 Theory of Computation
CISC 4090 Theory of Computation Context-Free Languages and Push Down Automata Professor Daniel Leeds dleeds@fordham.edu JMH 332 Languages: Regular and Beyond Regular: Captured by Regular Operations a b
More informationSCHEME FOR INTERNAL ASSESSMENT TEST 3
SCHEME FOR INTERNAL ASSESSMENT TEST 3 Max Marks: 40 Subject& Code: Automata Theory & Computability (15CS54) Sem: V ISE (A & B) Note: Answer any FIVE full questions, choosing one full question from each
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 informationCPSC 421: Tutorial #1
CPSC 421: Tutorial #1 October 14, 2016 Set Theory. 1. Let A be an arbitrary set, and let B = {x A : x / x}. That is, B contains all sets in A that do not contain themselves: For all y, ( ) y B if and only
More informationCS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018
CS 301 Lecture 18 Decidable languages Stephen Checkoway April 2, 2018 1 / 26 Decidable language Recall, a language A is decidable if there is some TM M that 1 recognizes A (i.e., L(M) = A), and 2 halts
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 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 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 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 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 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 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 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 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 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 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 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 informationProperties of Context-Free Languages
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 seungjin@postech.ac.kr
More informationCSE 105 THEORY OF COMPUTATION. Spring 2018 review class
CSE 105 THEORY OF COMPUTATION Spring 2018 review class Today's learning goals Summarize key concepts, ideas, themes from CSE 105. Approach your final exam studying with confidence. Identify areas to focus
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 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 informationLecture III CONTEXT FREE LANGUAGES
1. Context Free Languages and Grammar Lecture III Page 1 Lecture III CONTEXT FREE LANGUAGES Lecture 3: Honors Theory, Spring 02. We introduce context free languages (CFL), context free grammar (CFG) and
More informationContext Free Languages (CFL) Language Recognizer A device that accepts valid strings. The FA are formalized types of language recognizer.
Context Free Languages (CFL) Language Recognizer A device that accepts valid strings. The FA are formalized types of language recognizer. Language Generator: Context free grammars are language generators,
More informationContext Free Languages. Automata Theory and Formal Grammars: Lecture 6. Languages That Are Not Regular. Non-Regular Languages
Context Free Languages Automata Theory and Formal Grammars: Lecture 6 Context Free Languages Last Time Decision procedures for FAs Minimum-state DFAs Today The Myhill-Nerode Theorem The Pumping Lemma Context-free
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 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 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 informationDD2371 Automata Theory
KTH CSC VT 2008 DD2371 Automata Theory Dilian Gurov Lecture Outline 1. The lecturer 2. Introduction to automata theory 3. Course syllabus 4. Course objectives 5. Course organization 6. First definitions
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 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 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 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 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 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 5
Computational Models Lecture 5 One More PDAs Example Equivalence of PDAs and CFLs Nondeterminism adds power to PDAs (not in book) Closure Properties of CFLs Algorithmic Aspects of PDAs and CFLs DFAs and
More information1 More finite deterministic automata
CS 125 Section #6 Finite automata October 18, 2016 1 More finite deterministic automata Exercise. Consider the following game with two players: Repeatedly flip a coin. On heads, player 1 gets a point.
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 informationCSE 105 THEORY OF COMPUTATION
CSE 105 THEORY OF COMPUTATION Spring 2017 http://cseweb.ucsd.edu/classes/sp17/cse105-ab/ Today's learning goals Summarize key concepts, ideas, themes from CSE 105. Approach your final exam studying with
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 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 informationCS5371 Theory of Computation. Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)
CS5371 Theory of Computation Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG) Objectives Recall that decidable languages are languages that can be decided by TM (that means,
More informationTheory of Computation (IX) Yijia Chen Fudan University
Theory of Computation (IX) Yijia Chen Fudan University Review The Definition of Algorithm Polynomials and their roots A polynomial is a sum of terms, where each term is a product of certain variables and
More informationFLAC Context-Free Grammars
FLAC Context-Free Grammars Klaus Sutner Carnegie Mellon Universality Fall 2017 1 Generating Languages Properties of CFLs Generation vs. Recognition 3 Turing machines can be used to check membership in
More information1. (a) Explain the procedure to convert Context Free Grammar to Push Down Automata.
Code No: R09220504 R09 Set No. 2 II B.Tech II Semester Examinations,December-January, 2011-2012 FORMAL LANGUAGES AND AUTOMATA THEORY Computer Science And Engineering Time: 3 hours Max Marks: 75 Answer
More informationNon-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 informationSYLLABUS. Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 3 : REGULAR EXPRESSIONS AND LANGUAGES
Contents i SYLLABUS UNIT - I CHAPTER - 1 : AUT UTOMA OMATA Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 2 : FINITE AUT UTOMA OMATA An Informal Picture of Finite Automata,
More informationFORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY Chomsky Normal Form and TURING MACHINES TUESDAY Feb 4 CHOMSKY NORMAL FORM A context-free grammar is in Chomsky normal form if every rule is of the form:
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 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 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 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 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 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 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 informationCS481F01 Solutions 8
CS481F01 Solutions 8 A. Demers 7 Dec 2001 1. Prob. 111 from p. 344 of the text. One of the following sets is r.e. and the other is not. Which is which? (a) { i L(M i ) contains at least 481 elements }
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 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 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 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 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 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 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 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 information3515ICT: Theory of Computation. Regular languages
3515ICT: Theory of Computation Regular languages Notation and concepts concerning alphabets, strings and languages, and identification of languages with problems (H, 1.5). Regular expressions (H, 3.1,
More informationAutomata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) October,
Automata & languages A primer on the Theory of Computation Laurent Vanbever www.vanbever.eu ETH Zürich (D-ITET) October, 5 2017 Part 3 out of 5 Last week, we learned about closure and equivalence of regular
More informationPart 3 out of 5. Automata & languages. A primer on the Theory of Computation. Last week, we learned about closure and equivalence of regular languages
Automata & languages A primer on the Theory of Computation Laurent Vanbever www.vanbever.eu Part 3 out of 5 ETH Zürich (D-ITET) October, 5 2017 Last week, we learned about closure and equivalence of regular
More informationDecidability (intro.)
CHAPTER 4 Decidability Contents Decidable Languages decidable problems concerning regular languages decidable problems concerning context-free languages The Halting Problem The diagonalization method The
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 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 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 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 information