Miscellaneous. Closure Properties Decision Properties
|
|
- Candice Todd
- 5 years ago
- Views:
Transcription
1 Miscellaneous Closure Properties Decision Properties 1
2 Closure Properties of CFL s CFL s are closed under union, concatenation, and Kleene closure. Also, under reversal, homomorphisms and inverse homomorphisms. But not under intersection or difference. 2
3 Closure of CFL s Under Union Let L and M be CFL s with grammars G and H, respectively. Assume G and H have no variables in common. Names of variables do not affect the language. Let S 1 and S 2 be the start symbols of G and H. 3
4 Closure Under Union (2) Form a new grammar for L M by combining all the symbols and productions of G and H. Then, add a new start symbol S. Add productions S -> S 1 S 2. 4
5 Closure Under Union (3) In the new grammar, all derivations start with S. The first step replaces S by either S 1 or S 2. In the first case, the result must be a string in L(G) = L, and in the second case a string in L(H) = M. 5
6 Closure of CFL s Under Concatenation Let L and M be CFL s with grammars G and H, respectively. Assume G and H have no variables in common. Let S 1 and S 2 be the start symbols of G and H. 6
7 Closure Under Concatenation (2) Form a new grammar for LM by starting with all symbols and productions of G and H. Add a new start symbol S. Add production S -> S 1 S 2. Every derivation from S results in a string in L followed by one in M. 7
8 Closure Under Star Let L have grammar G, with start symbol S 1. Form a new grammar for L* by introducing to G a new start symbol S and the productions S -> S 1 S ε. A rightmost derivation from S generates a sequence of zero or more S 1 s, each of which generates some string in L. 8
9 Closure of CFL s Under Reversal If L is a CFL with grammar G, form a grammar for L R by reversing the right side of every production. Example: Let G have S -> 0S1 01. The reversal of L(G) has grammar S -> 1S
10 Nonclosure Under Intersection Unlike the regular languages, the class of CFL s is not closed under. We know that L 1 = {0 n 1 n 2 n n > 1} is not a CFL (use the pumping lemma). However, L 2 = {0 n 1 n 2 i n > 1, i > 1} is. CFG: S -> AB, A -> 0A1 01, B -> 2B 2. So is L 3 = {0 i 1 n 2 n n > 1, i > 1}. But L 1 = L 2 L 3. 10
11 Nonclosure Under Difference We can prove something more general: Any class of languages that is closed under difference is closed under intersection. Proof: L M = L (L M). Thus, if CFL s were closed under difference, they would be closed under intersection, but they are not. 11
12 Intersection with a Regular Language Intersection of two CFL s need not be context free. But the intersection of a CFL with a regular language is always a CFL. Proof involves running a DFA in parallel with a PDA, and noting that the combination is a PDA. PDA s accept by final state. 12
13 DFA and PDA in Parallel Input DFA PDA Accept if both accept S t a c k Looks like the state of one PDA 13
14 The intersection of a context-free language and a regular language is a context-free language L1 context free L2 regular L1 L 2 context-free 14
15 Formal Construction Let the DFA A have transition function δ A. Let the PDA P have transition function δ P. States of combined PDA are [q,p], where q is a state of A and p a state of P. δ([q,p], a, X) contains ([δ A (q,a),r], α) if δ P (p, a, X) contains (r, α). Note a could be ε, in which case δ A (q,a) = q. 15
16 Formal Construction (2) Accepting states of combined PDA are those [q,p] such that q is an accepting state of A and p is an accepting state of P. Easy induction: ([q 0,p 0 ], w, Z 0 ) * ([q,p], ε, α) if and only if δ A (q 0,w) = q and in P: (p 0, w, Z 0 ) *(p, ε, α). 16
17 Machine M 1 Machine M 2 NPDA for L DFA for 1 L2 context-free regular Construct a new NPDA machine that accepts L1 L 2 M M simulates in parallel M1 and M 2 17
18 NPDA M M 2 1 DFA a, b c q1 q2 transition a p1 p2 transition NPDA M q1, p 1 a, b c q 2, p 2 transition 18
19 NPDA M M 2 1 DFA λ, b c q1 q2 transition p 1 NPDA M q 1, p 1 λ, b c q 2, p 1 transition 19
20 NPDA M M 2 1 DFA q 0 p 0 initial state initial state NPDA M q 0, p 0 Initial state 20
21 NPDA M M 2 1 DFA q 1 p 1 p 2 final state final states NPDA M q 1, p 1 q 1, p 2 final states 21
22 An Application of Regular Closure Prove that: L n n = { a b : n 100, n 0} is context-free 22
23 We know: n n { a b : n 0} is context-free 23
24 We also know: 100 L 1 = { a b 100 } is regular L1 = {( a + b) } { a b * } is regular 24
25 { a n b n } context-free 100 L1 = {( a + b) } { a b * regular 100 } (regular closure) n n { a b } L 1 context-free n n { a b } L1 = { a n b n : n 100, n 0} = L is context-free 25
26 Another Application of Regular Closure Prove that: L = { w: na = nb = n c } is not context-free 26
27 If L = { w: n = n = nc} a b is context-free Then (regular closure) L { a * b* c*} = { a n b n c n } context-free regular context-free Therefore, L is not context free Impossible!!! 27
28 Closure of CFL s Under String Homomorphism Let L be a CFL with grammar G. Let h be a homomorphism on the terminal symbols of G. Construct a grammar for h(l) by replacing each terminal symbol a by h(a). 28
29 String Homomorphism Map from Σ to * for two alphabets Σ and h: Σ * (assigns a string in to each symbol in Σ) Example: Σ = {0,1} and = {a,b,c} h(0) = abc h(1) = bb The map extends to strings over Σ as well Example: string 010 over Σ h*: Σ* * Example: h*(010) = h(0)h(1)h(0) = abcbbabc 29
30 String Homomorphism h* maps a language over Σ to a language over naturally h*(l) = {h*(w) w L) Theorem: If L Σ* is a CFL, and h: Σ *, then h*(l) is also a CFL, i.e. CFLs are closed under string homomorphism Proof: Consider G = <V, Σ, P, S> generates L. Construct G as follows for h*(l). G = <V Σ,, P, S> where P = P {a h(a) for every a Σ} Note: as many productions as many terminals added Clearly, G generates h*(l). G being a CFG, so is G. 30
31 Example: Closure Under Homomorphism G has productions S -> 0S1 01. h is defined by h(0) = ab, h(1) = ε. h(l(g)) has the grammar with productions S -> abs ab. 31
32 Substitution Let Σ be an alphabet and suppose for every a in Σ, we choose a language L a over alphabet The choice of languages defines a substitution on Σ and we refer to L a as s(a) for each a Σ Example: s(0) = {a n b n n 1}, s(1) = {aa, bb} is a substitution on alphabet Σ ={0, 1}. If w = a 1 a 2 a n is a string in Σ*, then s(w) is the language of all strings x 1 x 2 x n such that string x i s(a i ) for i = 1..n s(w) is a concatenation of the languages s(a 1 )s(a 2 ) s(a n ) s(l) is the union of s(w) for all strings in L 32
33 Substitution Example: s(0) = {a n b n n 1}, s(1) = {aa, bb} is a substitution on alphabet Σ ={0, 1}. s(0) is the set of strings with one or more a s followed by an equal number of b s s(1) is the finite language consisting of the two strings aa and bb Let w = 01. s(w) is the concatenation of the languages s(0)s(1). s(w) consists of all strings of the form a n b n aa and a n b n+2 n 1 Let L = L(0*) i.e. set of all strings of 0 s. s(l) = (s(0))*: all strings of the form a n1 b n1 a n2 b n2 a nk b nk k >= 0 and any sequence of positive integers n1, n2..nk Includes strings such as ε, aabbaaabbb, and abaabbabab 33
34 Substitution Theorem: If a substitution s assigns a CFL to every symbol in the alphabet of a CFL L, then s(l) is a CFL. Proof Let G = (V,, P, S) be grammar for L Let G a = (V a, T a, P a, S a ) be the grammar for each a with V V a =φ G = (V, T, P, S) for s(l) where V = V V a T = union of T a for all a P consists of» All productions in any P a for a» In productions of P, each terminal a is replaced by S a A detailed proof that this construction works Intuition: this replacement allows any string in L a to take the place of any 34 occurrence of a in any string of L.
35 Example (1) L = {0 n 1 n n 1}, generated by the grammar S 0S1 01, s(0) = {a n b m m n}, generated by the grammar S asb A; A aa ab, s(1) ={ab, abc}, generated by the grammar S aba, A c ε Rename second and third S s to S 0 and S 1 respectively. Rename second A to B. Resulting grammars are: S 0S1 01 S 0 as 0 b A; A aa ab S 1 abb; B c ε 35
36 Example(1) Contd... In the first grammar replace 0 by S 0 and 1 by S 1. The combined grammar: G = ({S, S 0, S 1, A, B}, {a, b}, P, S), where P = {S S 0 SS 1 S 0 S 1, S 0 as 0 b A, A aa ab, S 1 abb, B c ε} 36
37 Application of Substitution Closure under union of CFL s L a and L b Let L a and L b be CFLs. Then L a L b is s(l) where L = {a,b} {a,b} * and s(a) = L a, s(b) = L b Closure under concatenation of CFL s L a and L b Let L a and L b be CFLs. Then L a L b is s(l) where L = {ab} and s(a) = L a, s(b) = L b Work out yourself: Closure under Kleene s star (closure * and positive closure + ) of CFL s L 1 Closure under homomorphism of CFL L i for every a i 37
38 Closure of CFL s Under Inverse Homomorphism If L is a language and h is a homomorphism, then h -1 (L) is the set of strings w such that h(w) is in L. Let L be a CFL and h be a homomorphism. Then h -1 (L) is a CFL. Here, grammars don t help us. But a PDA construction serves nicely. Intuition: Let L = L(P) for some PDA P. Construct PDA P to accept h -1 (L). P simulates P, but keeps, as one component of a twocomponent state a buffer that holds the result of applying h to one input symbol. 38
39 Architecture of P Input: h(0) Buffer State of P Read first remaining symbol in buffer as if it were input to P. Stack of P 39
40 Formal Construction of P States are pairs [q, b], where: 1. q is a state of P. 2. b is a suffix of h(a) for some symbol a. Thus, only a finite number of possible values for b. Stack symbols of P are those of P. Start state of P is [q 0,ε]. 40
41 Construction of P (2) Input symbols of P are the symbols to which h applies. Final states of P are the states [q, ε] such that q is a final state of P. 41
42 Transitions of P 1. δ ([q, ε], a, X) = {([q, h(a)], X)} for any input symbol a of P and any stack symbol X. When the buffer is empty, P can reload it. 2. δ ([q, bw], ε, X) contains ([p, w], α) if δ(q, b, X) contains (p, α), where b is either an input symbol of P or ε. Simulate P from the buffer. 42
43 Proving Correctness of P We need to show that L(P ) = h -1 (L(P)). Key argument: P makes the transition ([q 0, ε], w, Z 0 ) *([q, x], ε, α) if and only if P makes transition (q 0, y, Z 0 ) *(q, ε, α), h(w) = yx, and x is a suffix of the last symbol of w. Proof in both directions is an induction on the number of moves made. 43
44 Equivalence of PDA, CFG Conversion of CFG to PDA Conversion of PDA to CFG 44
45 Overview When we talked about closure properties of regular languages, it was useful to be able to jump between RE and DFA representations. Similarly, CFG s and PDA s are both useful to deal with properties of the CFL s. 45
46 Overview (2) Also, PDA s, being algorithmic, are often easier to use when arguing that a language is a CFL. Example: It is easy to see how a PDA can recognize balanced parentheses; not so easy as a grammar. But all depends on knowing that CFG s and PDA s both define the CFL s. 46
47 Converting a CFG to a PDA Let L = L(G). Construct PDA P such that N(P) = L. P has: One state q. Input symbols = terminals of G. Stack symbols = all symbols of G. Start symbol = start symbol of G. 47
48 Intuition About P Given input w, P will step through a leftmost derivation of w from the start symbol S. Since P can t know what this derivation is, or even what the end of w is, it uses nondeterminism to guess the production to use at each step. 48
49 Intuition (2) At each step, P represents some leftsentential form (step of a leftmost derivation). If the stack of P is α, and P has so far consumed x from its input, then P represents left-sentential form xα. At empty stack, the input consumed is a string in L(G). 49
50 Transition Function of P 1. δ(q, a, a) = (q, ε). (Type 1 rules) This step does not change the LSF represented, but moves responsibility for a from the stack to the consumed input. 2. If A -> α is a production of G, then δ(q, ε, A) contains (q, α). (Type 2 rules) Guess a production for A, and represent the next LSF in the derivation. 50
51 Example Grammar G: S asb ab PDA: δ(q, ε, S) contains (q, asb) and (q,ab) nondeterministic move δ(q, a, a) contains (q, ε) δ(q, b, b) contains (q, ε) Simulate it on aaabbb 51
52 Proof That L(P) = L(G) We need to show that (q, wx, S) * (q, x, α) for any x if and only if S =>* lm wα. Part 1: only if is an induction on the number of steps made by P. Basis: 0 steps. Then α = S, w = ε, and S =>* lm S is surely true. 52
53 Induction for Part 1 Consider n moves of P: (q, wx, S) * (q, x, α) and assume the IH for sequences of n-1 moves. There are two cases, depending on whether the last move uses a Type 1 or Type 2 rule. 53
54 Use of a Type 1 Rule The move sequence must be of the form (q, yax, S) * (q, ax, aα) (q, x, α), where ya = w. By the IH applied to the first n-1 steps, S =>* lm yaα. But ya = w, so S =>* lm wα. 54
55 Use of a Type 2 Rule The move sequence must be of the form (q, wx, S) * (q, x, Aβ) (q, x, γβ), where A -> γ is a production and α = γβ. By the IH applied to the first n-1 steps, S =>* lm waβ. Thus, S =>* lm wγβ = wα. 55
56 Proof of Part 2 ( if ) We also must prove that if S =>* lm wα, then (q, wx, S) * (q, x, α) for any x. Induction on number of steps in the leftmost derivation. Ideas are similar; read in text. 56
57 Proof Completion We now have (q, wx, S) * (q, x, α) for any x if and only if S =>* lm wα. In particular, let x = α = ε. Then (q, w, S) * (q, ε, ε) if and only if S =>* lm w. That is, w is in N(P) if and only if w is in L(G). 57
58 From a PDA to a CFG Now, assume L = N(P). We ll construct a CFG G such that L = L(G). Intuition: G will have variables generating exactly the inputs that cause P to have the net effect of popping a stack symbol X while going from state p to state q. P never gets below this X while doing so. 58
59 Variables of G G s variables are of the form [pxq]. This variable generates all and only the strings w such that (p, w, X) *(q, ε, ε). Also a start symbol S we ll talk about later. 59
60 Productions of G Each production for [pxq] comes from a move of P in state p with stack symbol X. Simplest case: δ(p, a, X) contains (q, ε). Then the production is [pxq] -> a. Note a can be an input symbol or ε. Here, [pxq] generates a, because reading a is one way to pop X and go from p to q. 60
61 Productions of G (2) Next simplest case: δ(p, a, X) contains (r, Y) for some state r and symbol Y. G has production [pxq] -> a[ryq]. We can erase X and go from p to q by reading a (entering state r and replacing the X by Y) and then reading some w that gets P from r to q while erasing the Y. Note: [pxq] =>* aw whenever [ryq] =>* w. 61
62 Productions of G (3) Third simplest case: δ(p, a, X) contains (r, YZ) for some state r and symbols Y and Z. Now, P has replaced X by YZ. To have the net effect of erasing X, P must erase Y, going from state r to some state s, and then erase Z, going from s to q. 62
63 Picture of Action of P a w x w x x p r s q X Y Z Z 63
64 Third-Simplest Case Concluded Since we do not know state s, we must generate a family of productions: [pxq] -> a[rys][szq] for all states s. [pxq] =>* awx whenever [rys] =>* w and [szq] =>* x. 64
65 Productions of G: General Case Suppose δ(p, a, X) contains (r, Y 1, Y k ) for some state r and k > 3. Generate family of productions [pxq] -> a[ry 1 s 1 ][s 1 Y 2 s 2 ] [s k-2 Y k-1 s k-1 ][s k-1 Y k q] 65
66 Completion of the Construction We can prove that (q 0, w, Z 0 ) *(p, ε, ε) if and only if [q 0 Z 0 p] =>* w. Proof is in text; it is two easy inductions. But state p can be anything. Thus, add to G another variable S, the start symbol, and add productions S -> [q 0 Z 0 p] for each state p. 66
Properties 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 informationEquivalence of CFG s and PDA s
Equivalence of CFG s and PDA s Mridul Aanjaneya Stanford University July 24, 2012 Mridul Aanjaneya Automata Theory 1/ 53 Recap: Pushdown Automata A PDA is an automaton equivalent to the CFG in language-defining
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 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 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 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 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 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 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 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 informationUNIT-VI PUSHDOWN AUTOMATA
Syllabus R09 Regulation UNIT-VI PUSHDOWN AUTOMATA The context free languages have a type of automaton that defined them. This automaton, called a pushdown automaton, is an extension of the nondeterministic
More informationHKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed
HKN CS/ECE 374 Midterm 1 Review Nathan Bleier and Mahir Morshed For the most part, all about strings! String induction (to some extent) Regular languages Regular expressions (regexps) Deterministic finite
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 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 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 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 information(pp ) PDAs and CFGs (Sec. 2.2)
(pp. 117-124) PDAs and CFGs (Sec. 2.2) A language is context free iff all strings in L can be generated by some context free grammar Theorem 2.20: L is Context Free iff a PDA accepts it I.e. if L is context
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 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 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 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 informationCFGs and PDAs are Equivalent. We provide algorithms to convert a CFG to a PDA and vice versa.
CFGs and PDAs are Equivalent We provide algorithms to convert a CFG to a PDA and vice versa. CFGs and PDAs are Equivalent We now prove that a language is generated by some CFG if and only if it is accepted
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 informationOctober 6, Equivalence of Pushdown Automata with Context-Free Gramm
Equivalence of Pushdown Automata with Context-Free Grammar October 6, 2013 Motivation Motivation CFG and PDA are equivalent in power: a CFG generates a context-free language and a PDA recognizes a context-free
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 Define push down automata Trace the computation of a push down automaton Design
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 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 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 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 informationAccept or reject. Stack
Pushdown Automata CS351 Just as a DFA was equivalent to a regular expression, we have a similar analogy for the context-free grammar. A pushdown automata (PDA) is equivalent in power to contextfree grammars.
More information(pp ) PDAs and CFGs (Sec. 2.2)
(pp. 117-124) PDAs and CFGs (Sec. 2.2) A language is context free iff all strings in L can be generated by some context free grammar Theorem 2.20: L is Context Free iff a PDA accepts it I.e. if L is context
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 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 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 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 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 informationMTH401A Theory of Computation. Lecture 17
MTH401A Theory of Computation Lecture 17 Chomsky Normal Form for CFG s Chomsky Normal Form for CFG s For every context free language, L, the language L {ε} has a grammar in which every production looks
More informationPushdown Automata (2015/11/23)
Chapter 6 Pushdown Automata (2015/11/23) Sagrada Familia, Barcelona, Spain Outline 6.0 Introduction 6.1 Definition of PDA 6.2 The Language of a PDA 6.3 Euivalence of PDA s and CFG s 6.4 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 (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 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 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 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 informationCS481F01 Prelim 2 Solutions
CS481F01 Prelim 2 Solutions A. Demers 7 Nov 2001 1 (30 pts = 4 pts each part + 2 free points). For this question we use the following notation: x y means x is a prefix of y m k n means m n k For each of
More informationCSE 105 THEORY OF COMPUTATION
CSE 105 THEORY OF COMPUTATION Spring 2017 http://cseweb.ucsd.edu/classes/sp17/cse105-ab/ Review of CFG, CFL, ambiguity What is the language generated by the CFG below: G 1 = ({S,T 1,T 2 }, {0,1,2}, { S
More informationECS 120: Theory of Computation UC Davis Phillip Rogaway February 16, Midterm Exam
ECS 120: Theory of Computation Handout MT UC Davis Phillip Rogaway February 16, 2012 Midterm Exam Instructions: The exam has six pages, including this cover page, printed out two-sided (no more wasted
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 informationContext Free Grammars
Automata and Formal Languages Context Free Grammars Sipser pages 101-111 Lecture 11 Tim Sheard 1 Formal Languages 1. Context free languages provide a convenient notation for recursive description of languages.
More informationCSE 468, Fall 2006 Homework solutions 1
CSE 468, Fall 2006 Homework solutions 1 Homework 1 Problem 1. (a) To accept digit strings that contain 481: Q ={λ,4,48, 481}, Σ ={0,1,...,9}, q 0 = λ, A ={481}. To define δ, weuse a for all letters (well,
More informationT (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is,
Recall A deterministic finite automaton is a five-tuple where S is a finite set of states, M = (S, Σ, T, s 0, F ) Σ is an alphabet the input alphabet, T : S Σ S is the transition function, s 0 S is the
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 informationPushdown Automata: Introduction (2)
Pushdown Automata: Introduction Pushdown automaton (PDA) M = (K, Σ, Γ,, s, A) where K is a set of states Σ is an input alphabet Γ is a set of stack symbols s K is the start state A K is a set of accepting
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 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 informationSolutions to Old Final Exams (For Fall 2007)
Solutions to Old Final Exams (For Fall 2007) CS 381 (Fall 2002, Fall 2004, Fall 2005, Fall 2006) Yogi Sharma Disclaimer: I, Yogi Sharma, do not claim these solution to be complete, or even to be absolutely
More informationCDM Parsing and Decidability
CDM Parsing and Decidability 1 Parsing Klaus Sutner Carnegie Mellon Universality 65-parsing 2017/12/15 23:17 CFGs and Decidability Pushdown Automata The Recognition Problem 3 What Could Go Wrong? 4 Problem:
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 informationEinführung in die Computerlinguistik
Einführung in die Computerlinguistik Context-Free Grammars (CFG) Laura Kallmeyer Heinrich-Heine-Universität Düsseldorf Summer 2016 1 / 22 CFG (1) Example: Grammar G telescope : Productions: S NP VP NP
More informationCS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,
CS 54, Lecture 2: Finite Automata, Closure Properties Nondeterminism, Why so Many Models? Streaming Algorithms 0 42 Deterministic Finite Automata Anatomy of Deterministic Finite Automata transition: for
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 informationNondeterministic Finite Automata. Nondeterminism Subset Construction
Nondeterministic Finite Automata Nondeterminism Subset Construction 1 Nondeterminism A nondeterministic finite automaton has the ability to be in several states at once. Transitions from a state on an
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 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 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 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 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 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 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 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 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 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 informationNondeterministic Finite Automata
Nondeterministic Finite Automata Not A DFA Does not have exactly one transition from every state on every symbol: Two transitions from q 0 on a No transition from q 1 (on either a or b) Though not a DFA,
More informationSri vidya college of engineering and technology
Unit I FINITE AUTOMATA 1. Define hypothesis. The formal proof can be using deductive proof and inductive proof. The deductive proof consists of sequence of statements given with logical reasoning in order
More informationCS 455/555: Finite automata
CS 455/555: Finite automata Stefan D. Bruda Winter 2019 AUTOMATA (FINITE OR NOT) Generally any automaton Has a finite-state control Scans the input one symbol at a time Takes an action based on the currently
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 informationCS Pushdown Automata
Chap. 6 Pushdown Automata 6.1 Definition of Pushdown Automata Example 6.2 L ww R = {ww R w (0+1) * } Palindromes over {0, 1}. A cfg P 0 1 0P0 1P1. Consider a FA with a stack(= a Pushdown automaton; PDA).
More informationHomework 8. a b b a b a b. two-way, read/write
Homework 8 309 Homework 8 1. Describe a TM that accepts the set {a n n is a power of 2}. Your description should be at the level of the descriptions in Lecture 29 of the TM that accepts {ww w Σ } and the
More informationUNIT-II. NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: SIGNIFICANCE. Use of ε-transitions. s t a r t. ε r. e g u l a r
Syllabus R9 Regulation UNIT-II NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: In the automata theory, a nondeterministic finite automaton (NFA) or nondeterministic finite state machine is a finite
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 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 informationPushdown Automata (PDA) The structure and the content of the lecture is based on
Pushdown Automata (PDA) The structure and the content of the lecture is based on http://www.eecs.wsu.edu/~ananth/cpts317/lectures/index.htm 1 Excursion: Previous lecture n Context-free grammar G=(V,T,P,S),
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 informationUses of finite automata
Chapter 2 :Finite Automata 2.1 Finite Automata Automata are computational devices to solve language recognition problems. Language recognition problem is to determine whether a word belongs to a language.
More informationHarvard CS 121 and CSCI E-207 Lecture 10: Ambiguity, Pushdown Automata
Harvard CS 121 and CSCI E-207 Lecture 10: Ambiguity, Pushdown Automata Salil Vadhan October 4, 2012 Reading: Sipser, 2.2. Another example of a CFG (with proof) L = {x {a, b} : x has the same # of a s and
More information