Formal Languages and Automata
|
|
- Barnaby O’Brien’
- 6 years ago
- Views:
Transcription
1 Formal Languages and Automata Lecture LFAC ( ) Lecture 6 1 / 31
2 Lecture 6 1 The recognition problem: the Cocke Younger Kasami algorithm 2 Pushdown Automata 3 Pushdown Automata and Context-free Languages 4 Deterministic pushdown automata LFAC ( ) Lecture 6 2 / 31
3 The recognition problem: the Cocke Younger Kasami algorithm Lecture 6 1 The recognition problem: the Cocke Younger Kasami algorithm 2 Pushdown Automata 3 Pushdown Automata and Context-free Languages 4 Deterministic pushdown automata LFAC ( ) Lecture 6 3 / 31
4 The recognition problem: the Cocke Younger Kasami algorithm The Cocke Younger Kasami (CYK) Agorithm The recognition problem in grammars that are in Chomsky Normal Form can be solved using the CYK algorithm in O(n 3 ). If w = a 1 a 2...a n then we build the sets V ij = {A A + a i a i+1...a i+j 1 } inductively, for j = 1,...,n w L(G) S V 1n LFAC ( ) Lecture 6 4 / 31
5 The recognition problem: the Cocke Younger Kasami algorithm The Cocke Younger Kasami Algorithm For j = 1: V i1 = {A A + a i } = {A A a i P} For j > 1, V ij : If A + a i a i+1...a i+j 1 : A BC + a i a i+1...a i+j 1 and B + a i a i+1...a i+k 1 (B V ik ) C + a i+k a i+k+1...a i+j 1 (C V i+k j k ) where 1 i n+1 j, 1 k j 1 V ij = j 1 k=1 {A A BC P, B V ik, C V i+k j k } LFAC ( ) Lecture 6 5 / 31
6 The recognition problem: the Cocke Younger Kasami algorithm The Cocke Younger Kasami Algorithm Notation: {A A BC P, B V ik, C V i+k j k } = V ik V i+k j k Then: for 2 j n, 1 i n+1 j : V ij = j 1 (V ik V i+k j k ) k=1 LFAC ( ) Lecture 6 6 / 31
7 The recognition problem: the Cocke Younger Kasami algorithm The Cocke Younger Kasami Algorithm Input: G = (N, T, S, P) in Chomsky Normal Form, w = a 1 a 2...a n Output: w L(G)? for(i=1; i<=n; i++) V i1 = {A A a i P}; for(j=2; j<=n; j++) for (i=1; i<=n+1-j; i++){ V ij = ; for(k=1; k<=j-1; k++) V ij = V ij (V ik V i+k j k ); } if(s V 1n ) w L(G) else w L(G) LFAC ( ) Lecture 6 7 / 31
8 The recognition problem: the Cocke Younger Kasami algorithm Example G = ({S, X, Y, Z},{a, b, c}, S, P), where P: S XY X XY a Y YZ a b Z c w = abc LFAC ( ) Lecture 6 8 / 31
9 The recognition problem: the Cocke Younger Kasami algorithm Example G = ({S, X, Y, Z},{a, b, c}, S, P), where P: S XY X XY a Y YZ a b Z c w = abc V 11 = {X, Y} V 12 = {S, X} V 13 = {S, X} V 21 = {Y} V 22 = {Y} V 31 = {Z} S V 13 abc L(G) LFAC ( ) Lecture 6 8 / 31
10 Lecture 6 1 The recognition problem: the Cocke Younger Kasami algorithm 2 Pushdown Automata 3 Pushdown Automata and Context-free Languages 4 Deterministic pushdown automata LFAC ( ) Lecture 6 9 / 31
11 Pushdown Automata Finite automata + pushdown memory (stack) LFAC ( ) Lecture 6 10 / 31
12 Pushdown automata - definition Definition 1 A pushdown automaton: M = (Q,Σ,Γ,δ, q 0, z 0, F): Q is a finite set of states Σ is the input alphabet Γ is the stack alphabet q 0 Q is the initial state z 0 Γ is the initial symbol in the stack F Q is the set of final states δ : Q (Σ {ǫ}) Γ 2 Q Γ The model is non-deterministic LFAC ( ) Lecture 6 11 / 31
13 Configuration of a Pushdown Automata Configuration: (q, w,γ) Q Σ Γ 1 : γ (first symbol in γ) represents the top of the stack LFAC ( ) Lecture 6 12 / 31
14 Pushdown automata Pushdown Automata Initial configuration: (q 0, w, z 0 ) Q Σ Γ LFAC ( ) Lecture 6 13 / 31
15 The transition relation between configurations Configuration (q, aw, zβ) and (q,α) δ(q, a, z) (q, q Q, a Σ {ǫ}, z Γ, α,β Γ ) LFAC ( ) Lecture 6 14 / 31
16 The transition relation between configurations (q, aw, zβ) (q, w,αβ) LFAC ( ) Lecture 6 15 / 31
17 The transition relation between configurations Let M = (Q,Σ,Γ,δ, q 0, z 0, F) be a pushdown automaton. The transition relation between configurations: (q, aw, zβ) (q, w,αβ) if (q,α) δ(q, a, z) (q, q Q, a Σ {ǫ}, z Γ, α,β Γ ) Computation: the transitive and reflexive closure of the transition relation: C 1,...,C n configurations such that: C 1 C 2... C n written: C 1 + C n if n 2, C 1 C n, if n 1 LFAC ( ) Lecture 6 16 / 31
18 Recognized language By final states (if F ) L(M) = {w Σ (q 0, w, z 0 ) (q,ǫ,γ), q F, γ Γ } By empty stack (if F = ) L ǫ (M) = {w Σ (q 0, w, z 0 ) (q,ǫ,ǫ), q Q} LFAC ( ) Lecture 6 17 / 31
19 Example Automaton which recognizes the language {a n b n n 1}: M = ({q 0, q 1, q 2 },{a, b},{a, z},δ, q 0, z,{q 2 }) 1 δ(q 0, a, z) = {(q 0, az)} 2 δ(q 0, a, a) = {(q 0, aa)} 3 δ(q 0, b, a) = {(q 1,ǫ)} 4 δ(q 1, b, a) = {(q 1,ǫ)} 5 δ(q 1,ǫ, z) = {(q 2,ǫ)} LFAC ( ) Lecture 6 18 / 31
20 Examples Pushdown automaton which recognizes the language {waw R w {0, 1} } LFAC ( ) Lecture 6 19 / 31
21 Examples Pushdown automaton which recognizes the language {waw R w {0, 1} } Every 0 or 1 read is added to the stack a in the input changes the state LFAC ( ) Lecture 6 19 / 31
22 Examples Pushdown automaton which recognizes the language {waw R w {0, 1} } Every 0 or 1 read is added to the stack a in the input changes the state after reading a, for every symbol read from the input, the same symbol must be removed from the stack M = ({q 0, q 1, q 2 },{0, 1, a},{0, 1, z},δ, q 0, z,{q 2 }) 1 δ(q 0, i, z) = {(q 0, iz)}, (i {0, 1}) 2 δ(q 0, i, j) = {(q 0, ij)}, (i, j {0, 1}) 3 δ(q 0, a, i) = {(q 1, i)} 4 δ(q 1, i, i) = {(q 1,ǫ)} 5 δ(q 1,ǫ, z) = {(q 2,ǫ)} LFAC ( ) Lecture 6 19 / 31
23 Examples Pushdown automaton which recognizes the language {waw R w {0, 1} } Every 0 or 1 read is added to the stack a in the input changes the state after reading a, for every symbol read from the input, the same symbol must be removed from the stack M = ({q 0, q 1, q 2 },{0, 1, a},{0, 1, z},δ, q 0, z,{q 2 }) 1 δ(q 0, i, z) = {(q 0, iz)}, (i {0, 1}) 2 δ(q 0, i, j) = {(q 0, ij)}, (i, j {0, 1}) 3 δ(q 0, a, i) = {(q 1, i)} 4 δ(q 1, i, i) = {(q 1,ǫ)} 5 δ(q 1,ǫ, z) = {(q 2,ǫ)} Pushdown automaton for {ww R w {0, 1} }? LFAC ( ) Lecture 6 19 / 31
24 Examples Pushdown automaton which recognizes the language {waw R w {0, 1} } Every 0 or 1 read is added to the stack a in the input changes the state after reading a, for every symbol read from the input, the same symbol must be removed from the stack M = ({q 0, q 1, q 2 },{0, 1, a},{0, 1, z},δ, q 0, z,{q 2 }) 1 δ(q 0, i, z) = {(q 0, iz)}, (i {0, 1}) 2 δ(q 0, i, j) = {(q 0, ij)}, (i, j {0, 1}) 3 δ(q 0, a, i) = {(q 1, i)} 4 δ(q 1, i, i) = {(q 1,ǫ)} 5 δ(q 1,ǫ, z) = {(q 2,ǫ)} Pushdown automaton for {ww R w {0, 1} }? Pushdown automaton for {ww w {0, 1} }? LFAC ( ) Lecture 6 19 / 31
25 Pushdwon automata with final states and without final states Theorem 1 For any pushdown automaton M with F =, there exists a pushdown automaton M with final states such that L(M ) = L ǫ (M). LFAC ( ) Lecture 6 20 / 31
26 Pushdwon automata with final states and without final states Theorem 1 For any pushdown automaton M with F =, there exists a pushdown automaton M with final states such that L(M ) = L ǫ (M). If M = (Q,Σ,Γ,δ, q 0, z 0, ), let M = (Q {q f, q 0 },Σ,Γ {z 0 },δ, q 0, z 0,{q f}) with δ : LFAC ( ) Lecture 6 20 / 31
27 Pushdwon automata with final states and without final states Theorem 1 For any pushdown automaton M with F =, there exists a pushdown automaton M with final states such that L(M ) = L ǫ (M). If M = (Q,Σ,Γ,δ, q 0, z 0, ), let M = (Q {q f, q 0 },Σ,Γ {z 0 },δ, q 0, z 0,{q f}) with δ : 1 δ (q 0,ǫ, z 0 ) = {(q 0, z 0 z 0 )} (without reading any symbol, M goes to the initial configuration of M) LFAC ( ) Lecture 6 20 / 31
28 Pushdwon automata with final states and without final states Theorem 1 For any pushdown automaton M with F =, there exists a pushdown automaton M with final states such that L(M ) = L ǫ (M). If M = (Q,Σ,Γ,δ, q 0, z 0, ), let M = (Q {q f, q 0 },Σ,Γ {z 0 },δ, q 0, z 0,{q f}) with δ : 1 δ (q 0,ǫ, z 0 ) = {(q 0, z 0 z 0 )} (without reading any symbol, M goes to the initial configuration of M) 2 δ (q, a, z) = δ(q, a, z), q Q, a Σ {ǫ}, z Γ (M makes the same transitions as M) LFAC ( ) Lecture 6 20 / 31
29 Pushdwon automata with final states and without final states Theorem 1 For any pushdown automaton M with F =, there exists a pushdown automaton M with final states such that L(M ) = L ǫ (M). If M = (Q,Σ,Γ,δ, q 0, z 0, ), let M = (Q {q f, q 0 },Σ,Γ {z 0 },δ, q 0, z 0,{q f}) with δ : 1 δ (q 0,ǫ, z 0 ) = {(q 0, z 0 z 0 )} (without reading any symbol, M goes to the initial configuration of M) 2 δ (q, a, z) = δ(q, a, z), q Q, a Σ {ǫ}, z Γ (M makes the same transitions as M) 3 δ (q,ǫ, z 0 ) = {(q f,ǫ)}, q Q (M goes into a final state only if the stack of M is empty) LFAC ( ) Lecture 6 20 / 31
30 Pushdwon automata with final states and without final states Theorem 2 For every pushdown automaton M with F, there exists a pushdown automaton M with F = such that L ǫ (M ) = L(M). LFAC ( ) Lecture 6 21 / 31
31 Pushdwon automata with final states and without final states Theorem 2 For every pushdown automaton M with F, there exists a pushdown automaton M with F = such that L ǫ (M ) = L(M). If M = (Q,Σ,Γ,δ, q 0, z 0, F), let M = (Q {q ǫ, q 0 },Σ,Γ {z 0 },δ, q 0, z 0, ) LFAC ( ) Lecture 6 21 / 31
32 Proof M = (Q {q ǫ, q 0 },Σ,Γ {z 0 },δ, q 0, z 0, ), with δ : LFAC ( ) Lecture 6 22 / 31
33 Proof M = (Q {q ǫ, q 0 },Σ,Γ {z 0 },δ, q 0, z 0, ), with δ : 1 δ (q 0,ǫ, z 0 ) = {(q 0, z 0 z 0 )} (without reading any symbol, M goes into the initial configuration of M) LFAC ( ) Lecture 6 22 / 31
34 Proof M = (Q {q ǫ, q 0 },Σ,Γ {z 0 },δ, q 0, z 0, ), with δ : 1 δ (q 0,ǫ, z 0 ) = {(q 0, z 0 z 0 )} (without reading any symbol, M goes into the initial configuration of M) 2 a) δ (q, a, z) = δ(q, a, z), q Q, a Σ, z Γ (M makes the same transitions as f M, for any symbol read from the input) b) δ (q,ǫ, z) = δ(q,ǫ, z), if q Q \ F, z Γ (M makes the same ǫ-transitions as M, if the state is non-final ) c) δ (q,ǫ, z) = δ(q,ǫ, z) {(q ǫ,ǫ)}, q F, z Γ (if M goes into a final state, M can go into a special state ) LFAC ( ) Lecture 6 22 / 31
35 Proof M = (Q {q ǫ, q 0 },Σ,Γ {z 0 },δ, q 0, z 0, ), with δ : 1 δ (q 0,ǫ, z 0 ) = {(q 0, z 0 z 0 )} (without reading any symbol, M goes into the initial configuration of M) 2 a) δ (q, a, z) = δ(q, a, z), q Q, a Σ, z Γ (M makes the same transitions as f M, for any symbol read from the input) b) δ (q,ǫ, z) = δ(q,ǫ, z), if q Q \ F, z Γ (M makes the same ǫ-transitions as M, if the state is non-final ) c) δ (q,ǫ, z) = δ(q,ǫ, z) {(q ǫ,ǫ)}, q F, z Γ (if M goes into a final state, M can go into a special state ) 3 δ (q,ǫ, z 0 ) = {(q ǫ,ǫ)}, if q F ( case 2(c), if the top of the stack is z 0 ) LFAC ( ) Lecture 6 22 / 31
36 Proof M = (Q {q ǫ, q 0 },Σ,Γ {z 0 },δ, q 0, z 0, ), with δ : 1 δ (q 0,ǫ, z 0 ) = {(q 0, z 0 z 0 )} (without reading any symbol, M goes into the initial configuration of M) 2 a) δ (q, a, z) = δ(q, a, z), q Q, a Σ, z Γ (M makes the same transitions as f M, for any symbol read from the input) b) δ (q,ǫ, z) = δ(q,ǫ, z), if q Q \ F, z Γ (M makes the same ǫ-transitions as M, if the state is non-final ) c) δ (q,ǫ, z) = δ(q,ǫ, z) {(q ǫ,ǫ)}, q F, z Γ (if M goes into a final state, M can go into a special state ) 3 δ (q,ǫ, z 0 ) = {(q ǫ,ǫ)}, if q F ( case 2(c), if the top of the stack is z 0 ) 4 δ (q ǫ,ǫ, z) = {(q ǫ,ǫ)}, if z Γ {z 0 } ( M remains in state q ǫ and pops the top of the stack) LFAC ( ) Lecture 6 22 / 31
37 Lecture 6 Pushdown Automata and Context-free Languages 1 The recognition problem: the Cocke Younger Kasami algorithm 2 Pushdown Automata 3 Pushdown Automata and Context-free Languages 4 Deterministic pushdown automata LFAC ( ) Lecture 6 23 / 31
38 and Context-free Languages The pushdown automaton equivalent to a type 2 grammar Theorem 3 For any type 2 grammar G there exists a pushdown automaton M without final states such that L ǫ (M) = L(G) LFAC ( ) Lecture 6 24 / 31
39 and Context-free Languages The pushdown automaton equivalent to a type 2 grammar Theorem 3 For any type 2 grammar G there exists a pushdown automaton M without final states such that L ǫ (M) = L(G) Let G = (N, T, S, P) The pushdown automaton: M = ({q}, T, N T,δ, q, S, ) where: 1 δ(q,ǫ, A) = {(q,β) A β P}, A N 2 δ(q, a, a) = {(q,ǫ)}, a T 3 δ(q, x, y) =, otherwise w L(G) S + w (q, w, S) + (q,ǫ,ǫ) w L ǫ (M) M simulates the leftmost derivations of G LFAC ( ) Lecture 6 24 / 31
40 and Context-free Languages Example G = ({x},{a, b}, x,{x axb, x ab}) The equivalent pushdown automaton: M = ({q},{a, b},{a, b, x},δ, q, x, ) 1 δ(q,ǫ, x) = {(q, axb),(q, ab)} 2 δ(q, a, a) = {(q,ǫ)} 3 δ(q, b, b) = {(q,ǫ)} LFAC ( ) Lecture 6 25 / 31
41 and Context-free Languages The grammar equivalent to a pushdown automaton Theorem 4 For any pushdown automaton M there exists a grammar G such that L(G) = L ǫ (M) LFAC ( ) Lecture 6 26 / 31
Foundations 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 informationC6.2 Push-Down Automata
Theory of Computer Science April 5, 2017 C6. Context-free Languages: Push-down Automata Theory of Computer Science C6. Context-free Languages: Push-down Automata Malte Helmert University of Basel April
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 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 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 informationFormal Languages, Automata and Compilers
Formal Languages, Automata and Compilers Lecure 4 2017-18 LFAC (2017-18) Lecture 4 1 / 31 Curs 4 1 Grammars of type 3 and finite automata 2 Closure properties for type 3 languages 3 Regular Expressions
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 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. 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 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 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 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 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 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 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 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 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 informationContext-Free Languages
CS:4330 Theory of Computation Spring 2018 Context-Free Languages Pushdown Automata Haniel Barbosa Readings for this lecture Chapter 2 of [Sipser 1996], 3rd edition. Section 2.2. Finite automaton 1 / 13
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 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 informationChapter 1. Formal Definition and View. Lecture Formal Pushdown Automata on the 28th April 2009
Chapter 1 Formal and View Lecture on the 28th April 2009 Formal of PA Faculty of Information Technology Brno University of Technology 1.1 Aim of the Lecture 1 Define pushdown automaton in a formal way
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 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 informationAutomata Theory - Quiz II (Solutions)
Automata Theory - Quiz II (Solutions) K. Subramani LCSEE, West Virginia University, Morgantown, WV {ksmani@csee.wvu.edu} 1 Problems 1. Induction: Let L denote the language of balanced strings over Σ =
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 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 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 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 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 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 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 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 informationLecture 2: Regular Expression
Lecture 2: Regular Expression Instructor: Ketan Mulmuley Scriber: Yuan Li January 8, 2015 In the last lecture, we proved that DFA, NFA, and NFA with ϵ-moves are equivalent. Recall that a language L Σ is
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 informationTheory of Computation Turing Machine and Pushdown Automata
Theory of Computation Turing Machine and Pushdown Automata 1. What is a Turing Machine? A Turing Machine is an accepting device which accepts the languages (recursively enumerable set) generated by type
More informationIntroduction to Formal Languages, Automata and Computability p.1/51
Introduction to Formal Languages, Automata and Computability Finite State Automata K. Krithivasan and R. Rama Introduction to Formal Languages, Automata and Computability p.1/51 Introduction As another
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 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 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 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 informationTesting Emptiness of a CFL. Testing Finiteness of a CFL. Testing Membership in a CFL. CYK Algorithm
Testing Emptiness of a CFL As for regular languages, we really take a representation of some language and ask whether it represents φ Can use either CFG or PDA Our choice, since there are algorithms to
More informationFormal Definition of a Finite Automaton. August 26, 2013
August 26, 2013 Why a formal definition? A formal definition is precise: - It resolves any uncertainties about what is allowed in a finite automaton such as the number of accept states and number of transitions
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 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 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 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 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 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 information3.13. PUSHDOWN AUTOMATA Pushdown Automata
3.13. PUSHDOWN AUTOMATA 317 3.13 Pushdown Automata We have seen that the regular languages are exactly the languages accepted by DFA s or NFA s. The context-free languages are exactly the languages accepted
More 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 informationFundamentele Informatica II
Fundamentele Informatica II Answer to selected exercises 5 John C Martin: Introduction to Languages and the Theory of Computation M.M. Bonsangue (and J. Kleijn) Fall 2011 5.1.a (q 0, ab, Z 0 ) (q 1, b,
More informationPushdown Automata (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 informationcse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska
cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska LECTURE 6 CHAPTER 2 FINITE AUTOMATA 2. Nondeterministic Finite Automata NFA 3. Finite Automata and Regular Expressions 4. Languages
More information5 Context-Free Languages
CA320: COMPUTABILITY AND COMPLEXITY 1 5 Context-Free Languages 5.1 Context-Free Grammars Context-Free Grammars Context-free languages are specified with a context-free grammar (CFG). Formally, a CFG G
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 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 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 informationMildly Context-Sensitive Grammar Formalisms: Embedded Push-Down Automata
Mildly Context-Sensitive Grammar Formalisms: Embedded Push-Down Automata Laura Kallmeyer Heinrich-Heine-Universität Düsseldorf Sommersemester 2011 Intuition (1) For a language L, there is a TAG G with
More informationThe Idea of a Pushdown Automaton
Pushdown Automata 5DV037 Fundamentals of Computer Science Umeå University Department of Computing Science Stephen J. Hegner hegner@cs.umu.se http://www.cs.umu.se/~hegner The Idea of a Pushdown Automaton
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 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 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 informationPush-down Automata = FA + Stack
Push-down Automata = FA + Stack PDA Definition A push-down automaton M is a tuple M = (Q,, Γ, δ, q0, F) where Q is a finite set of states is the input alphabet (of terminal symbols, terminals) Γ is the
More informationECS 120 Lesson 15 Turing Machines, Pt. 1
ECS 120 Lesson 15 Turing Machines, Pt. 1 Oliver Kreylos Wednesday, May 2nd, 2001 Before we can start investigating the really interesting problems in theoretical computer science, we have to introduce
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 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 informationOutline. CS21 Decidability and Tractability. Machine view of FA. Machine view of FA. Machine view of FA. Machine view of FA.
Outline CS21 Decidability and Tractability Lecture 5 January 16, 219 and Languages equivalence of NPDAs and CFGs non context-free languages January 16, 219 CS21 Lecture 5 1 January 16, 219 CS21 Lecture
More informationTheory of Computation
Thomas Zeugmann Hokkaido University Laboratory for Algorithmics http://www-alg.ist.hokudai.ac.jp/ thomas/toc/ Lecture 10: CF, PDAs and Beyond Greibach Normal Form I We want to show that all context-free
More informationcse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska
cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska LECTURE 11 CHAPTER 3 CONTEXT-FREE LANGUAGES 1. Context Free Grammars 2. Pushdown Automata 3. Pushdown automata and context -free
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 informationTAFL 1 (ECS-403) Unit- IV. 4.1 Push Down Automata. 4.2 The Formal Definition of Pushdown Automata. EXAMPLES for PDA. 4.3 The languages of PDA
TAFL 1 (ECS-403) Unit- IV 4.1 Push Down Automata 4.2 The Formal Definition of Pushdown Automata EXAMPLES for PDA 4.3 The languages of PDA 4.3.1 Acceptance by final state 4.3.2 Acceptance by empty stack
More informationFORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
5-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY NON-DETERMINISM and REGULAR OPERATIONS THURSDAY JAN 6 UNION THEOREM The union of two regular languages is also a regular language Regular Languages Are
More informationCPS 220 Theory of Computation Pushdown Automata (PDA)
CPS 220 Theory of Computation Pushdown Automata (PDA) Nondeterministic Finite Automaton with some extra memory Memory is called the stack, accessed in a very restricted way: in a First-In First-Out fashion
More informationAutomata Theory (2A) Young Won Lim 5/31/18
Automata Theory (2A) Copyright (c) 2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later
More informationHomework. Context Free Languages. Announcements. Before We Start. Languages. Plan for today. Final Exam Dates have been announced.
Homework Context Free Languages PDAs and CFLs Homework #3 returned Homework #4 due today Homework #5 Pg 169 -- Exercise 4 Pg 183 -- Exercise 4c,e,i (use JFLAP) Pg 184 -- Exercise 10 Pg 184 -- Exercise
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 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 informationCSE 211. Pushdown Automata. CSE 211 (Theory of Computation) Atif Hasan Rahman
CSE 211 Pushdown Automata CSE 211 (Theory of Computation) Atif Hasan Rahman Lecturer Department of Computer Science and Engineering Bangladesh University of Engineering & Technology Adapted from slides
More informationChapter Five: Nondeterministic Finite Automata
Chapter Five: Nondeterministic Finite Automata From DFA to NFA A DFA has exactly one transition from every state on every symbol in the alphabet. By relaxing this requirement we get a related but more
More informationFundamentele Informatica 3 Antwoorden op geselecteerde opgaven uit Hoofdstuk 7 en Hoofdstuk 8
Fundamentele Informatica 3 Antwoorden op geselecteerde opgaven uit Hoofdstuk 7 en Hoofdstuk 8 John Martin: Introduction to Languages and the Theory of Computation Jetty Kleijn Najaar 2008 7.1 (q 0,bbcbb,Z
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 informationEquivalence of DFAs and NFAs
CS 172: Computability and Complexity Equivalence of DFAs and NFAs It s a tie! DFA NFA Sanjit A. Seshia EECS, UC Berkeley Acknowledgments: L.von Ahn, L. Blum, M. Blum What we ll do today Prove that DFAs
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 informationFooling Sets and. Lecture 5
Fooling Sets and Introduction to Nondeterministic Finite Automata Lecture 5 Proving that a language is not regular Given a language, we saw how to prove it is regular (union, intersection, concatenation,
More informationProblem Session 5 (CFGs) Talk about the building blocks of CFGs: S 0S 1S ε - everything. S 0S0 1S1 A - waw R. S 0S0 0S1 1S0 1S1 A - xay, where x = y.
CSE2001, Fall 2006 1 Problem Session 5 (CFGs) Talk about the building blocks of CFGs: S 0S 1S ε - everything. S 0S0 1S1 A - waw R. S 0S0 0S1 1S0 1S1 A - xay, where x = y. S 00S1 A - xay, where x = 2 y.
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 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 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 informationAddress for Correspondence
Proceedings of BITCON-2015 Innovations For National Development National Conference on : Research and Development in Computer Science and Applications Research Paper SUBSTRING MATCHING IN CONTEXT FREE
More informationPushdown Automata (Pre Lecture)
Pushdown Automata (Pre Lecture) Dr. Neil T. Dantam CSCI-561, Colorado School of Mines Fall 2017 Dantam (Mines CSCI-561) Pushdown Automata (Pre Lecture) Fall 2017 1 / 41 Outline Pushdown Automata Pushdown
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 informationTheory of Computation
Theory of Computation Lecture #10 Sarmad Abbasi Virtual University Sarmad Abbasi (Virtual University) Theory of Computation 1 / 43 Lecture 10: Overview Linear Bounded Automata Acceptance Problem for LBAs
More informationPushdown Automata. Chapter 12
Pushdown Automata Chapter 12 Recognizing Context-Free Languages We need a device similar to an FSM except that it needs more power. The insight: Precisely what it needs is a stack, which gives it an unlimited
More informationUndecidable Problems and Reducibility
University of Georgia Fall 2014 Reducibility We show a problem decidable/undecidable by reducing it to another problem. One type of reduction: mapping reduction. Definition Let A, B be languages over Σ.
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 informationCSCI 1010 Models of Computa3on. Lecture 17 Parsing Context-Free Languages
CSCI 1010 Models of Computa3on Lecture 17 Parsing Context-Free Languages Overview BoCom-up parsing of CFLs. BoCom-up parsing via the CKY algorithm An O(n 3 ) algorithm John E. Savage CSCI 1010 Lect 17
More informationPlease give details of your answer. A direct answer without explanation is not counted.
Please give details of your answer. A direct answer without explanation is not counted. Your answers must be in English. Please carefully read problem statements. During the exam you are not allowed to
More informationComputability and Complexity
Computability and Complexity Lecture 5 Reductions Undecidable problems from language theory Linear bounded automata given by Jiri Srba Lecture 5 Computability and Complexity 1/14 Reduction Informal Definition
More informationPage 1. Compiler Lecture Note, (Regular Language) 컴파일러입문 제 3 장 정규언어. Database Lab. KHU
Page 1 컴파일러입문 제 3 장 정규언어 Page 2 목차 I. 정규문법과정규언어 II. 정규표현 III. 유한오토마타 VI. 정규언어의속성 Page 3 정규문법과정규언어 A study of the theory of regular languages is often justified by the fact that they model the lexical analysis
More information