CS 310 – Fall 2006 Pacific University CS310 Pushdown Automata Sections: 2.2 page 109 October 11, 2006.

Slides:



Advertisements
Similar presentations
Theory of Computation CS3102 – Spring 2014 A tale of computers, math, problem solving, life, love and tragic death Nathan Brunelle Department of Computer.
Advertisements

Chapter 5 Pushdown Automata
CFGs and PDAs Sipser 2 (pages ). Long long ago…
About Grammars CS 130 Theory of Computation HMU Textbook: Sec 7.1, 6.3, 5.4.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
PDAs => CFGs Sipser 2.2 (pages ). Last time…
PDAs => CFGs Sipser 2.2 (pages ). Last time…
CS5371 Theory of Computation
Theory of Computation What types of things are computable? How can we demonstrate what things are computable?
Introduction to the Theory of Computation John Paxton Montana State University Summer 2003.
Chap 2 Context-Free Languages. Context-free Grammars is not regular Context-free grammar : eg. G 1 : A  0A1substitution rules A  Bproduction rules B.
CS 310 – Fall 2006 Pacific University CS310 Pushdown Automata Sections: 2.2 page 109 October 9, 2006.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 4 Context-free grammars Jan Maluszynski, IDA, 2007
1 Normal Forms for Context-free Grammars. 2 Chomsky Normal Form All productions have form: variable and terminal.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2009 with acknowledgement.
Fall 2006Costas Busch - RPI1 Pushdown Automata PDAs.
January 14, 2015CS21 Lecture 51 CS21 Decidability and Tractability Lecture 5 January 14, 2015.
1 Normal Forms for Context-free Grammars. 2 Chomsky Normal Form All productions have form: variable and terminal.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
January 15, 2014CS21 Lecture 61 CS21 Decidability and Tractability Lecture 6 January 16, 2015.
Fall 2006Costas Busch - RPI1 PDAs Accept Context-Free Languages.
Fall 2005Costas Busch - RPI1 Pushdown Automata PDAs.
CS 3240: Languages and Computation Pushdown Automata & CF Grammars NOTE: THESE ARE ONLY PARTIAL SLIDES RELATED TO WEEKS 9 AND 10. PLEASE REFER TO THE TEXTBOOK.
1 Computer Language Theory Chapter 2: Context-Free Languages.
CSCI 2670 Introduction to Theory of Computing September 21, 2005.
نظریه زبان ها و ماشین ها فصل دوم Context-Free Languages دانشگاه صنعتی شریف بهار 88.
Pushdown Automata (PDA) Intro
CSCI 2670 Introduction to Theory of Computing September 20, 2005.
Normal Forms for Context-Free Grammars Definition: A symbol X in V  T is useless in a CFG G=(V, T, P, S) if there does not exist a derivation of the form.
CSCI 2670 Introduction to Theory of Computing September 21, 2004.
Pushdown Automata CS 130: Theory of Computation HMU textbook, Chap 6.
Pushdown Automata (PDAs)
Context-free Languages Chapter 2. Ambiguity.
Pushdown Automata Chapters Generators vs. Recognizers For Regular Languages: –regular expressions are generators –FAs are recognizers For Context-free.
1 Simplification of Context-Free Grammars Some useful substitution rules. Removing useless productions. Removing -productions. Removing unit-productions.
Closure Properties Lemma: Let A 1 and A 2 be two CF languages, then the union A 1  A 2 is context free as well. Proof: Assume that the two grammars are.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
PushDown Automata. What is a stack? A stack is a Last In First Out data structure where I only have access to the last element inserted in the stack.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
CSCI 2670 Introduction to Theory of Computing September 23, 2004.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 2 Context-Free Languages Some slides are in courtesy.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
CS 154 Formal Languages and Computability March 15 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
About Grammars Hopcroft, Motawi, Ullman, Chap 7.1, 6.3, 5.4.
Costas Busch - LSU1 PDAs Accept Context-Free Languages.
Theory of Computation Automata Theory Dr. Ayman Srour.
Lecture 11  2004 SDU Lecture7 Pushdown Automaton.
CSE 105 theory of computation
7. Properties of Context-Free Languages
Theorem 29 Given any PDA, there is another PDA that accepts exactly the same language with the additional property that whenever a path leads to ACCEPT,
Pushdown Automata PDAs
Pushdown Automata PDAs
CS 461 – Sept. 28 Section 2.2 – Pushdown Automata { 0n 1n }
Theory of Computation Lecture #27-28.
Pushdown automata and CFG ↔ PDA conversions
Context-free Languages
7. Properties of Context-Free Languages
Context-Free Languages
فصل دوم Context-Free Languages
Chapter 2 Context-Free Language - 01
CSE 105 theory of computation
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Pushdown automata The Chinese University of Hong Kong Fall 2011
CSE 105 theory of computation
Normal Forms for Context-free Grammars
CSE 105 theory of computation
Presentation transcript:

CS 310 – Fall 2006 Pacific University CS310 Pushdown Automata Sections: 2.2 page 109 October 11, 2006

CS 310 – Fall 2006 Pacific University Quick Review ε, ε -> $ 0, ε -> 0 1, 0 -> ε ε, $ -> ε a, b -> c Read a from input, read b from stack, push c onto stack to take this transition a = ε, read no input b = ε, don’t pop data from stack c = ε, don’t push data onto stack

CS 310 – Fall 2006 Pacific University Practice { ww R | w  {0, 1}* } hint: push symbols onto the stack, at each point guess that the middle of the string has been reached and begin popping from stack

CS 310 – Fall 2006 Pacific University Example L = { a i b j c k | i, j, k  0, i = j or i = k } –Hint: push as onto the stack, then pop and match with either bs or cs.

CS 310 – Fall 2006 Pacific University Theorem A Language is context free if and only if there exists a PDA that recognizes it. Lemma: –If a language is context free, the some PDA recognizes it –Show: a CFG can be transformed into a PDA Lemma: –If a PDA recognizes a language, the it is context free

CS 310 – Fall 2006 Pacific University Construct PDA from CFG L = {a n bb n | n  0 } S -> aSb | b S -> aSb -> aaSbb -> aabbb 1) Place $, start variable on stack 2) Repeat: a) if variable A is on top of stack, use replacement rule A (pop) -> w (push) b) if terminal on top, read input, compare. If match, repeat, else die c) if $ on top, enter accept, die if there’s more input

CS 310 – Fall 2006 Pacific University Example S -> aSb | b

CS 310 – Fall 2006 Pacific University Chomsky Normal Form CNF presents a grammar in a standard, simplified form: A -> BC A -> a S -> ε –Where A,B,C are variables and B and C are not the start variable –a is a terminal –The rule S -> ε is allowed so the language can generate the empty string (optional)

CS 310 – Fall 2006 Pacific University CNF Benefits Easier to prove statements about CFG’s when in CNF Any CFG can be converted to CNF Remove productions: A -> ε A -> B A -> s, s contains a terminal and |s| > 1 A -> s, |s| > 2 s  { V U ∑ }*

CS 310 – Fall 2006 Pacific University Removing A -> ε T -> UAV Remove:A -> ε Therefore:T -*> UV Add:T -> UV A variable A is nullable if A -*> ε Find all nullable variables Remove all ε transitions If T -> s 1 As 2 and A nullable then add T -> s 1 s 2

CS 310 – Fall 2006 Pacific University Example S -> TU T -> AB A -> aA | ε B -> bB | ε U -> ccA | B Nullable variables? Productions removed? Productions added?

CS 310 – Fall 2006 Pacific University Removing A -> B (Unit Productions) Remove: A -> B B -> s Therefore:A -*> s Add:A -> s s  { V U ∑ }* A variable B is A-derivable if A -*> B Find all A-derivable variables for each A Remove all unit transitions If B -> s and B is A-derivable then add A -> s

CS 310 – Fall 2006 Pacific University Example S -> TU | T | U T -> AB | A | B A -> aA | a B -> bB | b U -> ccA | B | cc S-derivable: T-derivable: U-derivable: Productions removed: Productions added:

CS 310 – Fall 2006 Pacific University Remove A -> S 1 aS 2 A -> S 1 aS 2 a  ∑, S 1 and S 2 strings, at least one is not empty Create X a -> a A -> S 1 X a S 2

CS 310 – Fall 2006 Pacific University Remove A -> S 1 X a S 2 A -> S 1 X a S 2 S 3 A -> S 1 W 1 W 1 -> X a W 2 W 2 -> S 2 S 3