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.

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
Pushdown Automata Section 2.2 CSC 4170 Theory of Computation.
Pushdown Automata CPSC 388 Ellen Walker Hiram College.
Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
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.
Pushdown Automata Part II: PDAs and CFG Chapter 12.
CS21 Decidability and Tractability
PDAs => CFGs Sipser 2.2 (pages ). Last time…
PDAs => CFGs Sipser 2.2 (pages ). Last time…
Introduction to Computability Theory
CFG => PDA Sipser 2 (pages ).
1 Introduction to Computability Theory Lecture7: PushDown Automata (Part 1) Prof. Amos Israeli.
CFG => PDA Sipser 2 (pages ). CS 311 Fall Formally… A pushdown automaton is a sextuple M = (Q, Σ, Γ, δ, q 0, F), where – Q is a finite set.
Costas Busch - RPI1 Pushdown Automata PDAs. Costas Busch - RPI2 Pushdown Automaton -- PDA Input String Stack States.
1 … NPDAs continued. 2 Pushing Strings Input symbol Pop symbol Push string.
Introduction to the Theory of Computation John Paxton Montana State University Summer 2003.
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
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2009 with acknowledgement.
Fall 2004COMP 3351 Pushdown Automata PDAs. Fall 2004COMP 3352 Pushdown Automaton -- PDA Input String Stack States.
Fall 2006Costas Busch - RPI1 Pushdown Automata PDAs.
January 14, 2015CS21 Lecture 51 CS21 Decidability and Tractability Lecture 5 January 14, 2015.
CS 490: Automata and Language Theory Daniel Firpo Spring 2003.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
Prof. Busch - LSU1 Pushdown Automata PDAs. Prof. Busch - LSU2 Pushdown Automaton -- PDA Input String Stack States.
Fall 2005Costas Busch - RPI1 Pushdown Automata PDAs.
1 Pushdown Automata PDAs. 2 Pushdown Automaton -- PDA Input String Stack States.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
CSCI 2670 Introduction to Theory of Computing September 21, 2005.
Pushdown Automata.
CSCI 2670 Introduction to Theory of Computing September 20, 2005.
Pushdown Automata CS 130: Theory of Computation HMU textbook, Chap 6.
Pushdown Automata (PDAs)
Pushdown Automata Part I: PDAs Chapter Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2)
CSCI 2670 Introduction to Theory of Computing September 22, 2005.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
Pushdown Automata Chapters Generators vs. Recognizers For Regular Languages: –regular expressions are generators –FAs are recognizers For Context-free.
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.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown.
Pushdown Automata Hopcroft, Motawi, Ullman, Chap 6.
Grammar Set of variables Set of terminal symbols Start variable Set of Production rules.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
Theory of Computation Automata Theory Dr. Ayman Srour.
Lecture 11  2004 SDU Lecture7 Pushdown Automaton.
CSCI 2670 Introduction to Theory of Computing September 22, 2004.
Recap: Nondeterministic Finite Automaton (NFA) A deterministic finite automaton (NFA) is a 5-tuple (Q, , ,s,F) where: Q is a finite set of elements called.
6. Pushdown Automata CIS Automata and Formal Languages – Pei Wang.
Formal Languages, Automata and Models of Computation
Pushdown Automata.
CSE 105 theory of computation
Pushdown Automata PDAs
Pushdown Automata PDAs
Pushdown Automata PDAs
Pushdown Automata PDAs
Context-Free Languages
Pushdown automata a_introduction.htm.
Chapter 2 Context-Free Language - 01
CSE 105 theory of computation
Principles of Computing – UFCFA3-30-1
… NPDAs continued.
Pushdown automata The Chinese University of Hong Kong Fall 2011
CSE 105 theory of computation
CSE 105 theory of computation
Presentation transcript:

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 FOR COMPLETE COVERAGE

Project 1

Pushdown Automata Similar to finite automata, but for CFG’s Finite automata are not adequate for CFG’s because we cannot keep track of what we’ve done  At any point, we only know the current state, not previous states Need memory  PDA’s are finite automata with a stack

FA and PDA Schematics State control a a b b State control a a b b xyzxyz FA PDA Stack: Infinite LIFO (last in first out) device

Formal Definition of PDA A pushdown automaton is a 6-tuple (Q, Σ, , , q 0, F), where Q, Σ, , and F are all finite sets, and  Q is the set of states  Σ is the set of input alphabet   is the stack alphabet   :Q×Σ  ×  ,  P(Q×   ) is the transition function  q 0 is the start state and  F  Q is the set of accept states

How does PDA work? Start in start state Read input character, perform state transition and update stack Clone a machine if multiple transitions are possible At end of input if any machine accepts and the stack is empty then accept

Example read 0 & push 0 on stack read ε & push ε on stack read ε & push $ on stack read 1 & pop 0 off stack read ε & pop $ off stack Language accepted: {0 n 1 n | n  0}

Example Read (()()) q start q accept ε, ε  S$ ε, $ εε, $ ε (,(  ε ),)  ε ε,S  SS ε,S  (S) ε,S  () S$S$ q loop

Example Read (()()) q start q accept ε, ε  S$ ε, $ εε, $ ε (,(  ε ),)  ε ε,S  SS ε,S  (S) ε,S  () q loop (S)$(S)$

Example Read (()()) q start q accept ε, ε  S$ ε, $ εε, $ ε (,(  ε ),)  ε ε,S  SS ε,S  (S) ε,S  () q loop S)$S)$ (

Example Read (()()) q start q accept ε, ε  S$ ε, $ εε, $ ε (,(  ε ),)  ε ε,S  SS ε,S  (S) ε,S  () q loop S SS)$SS)$ (

Example Read (()()) q start q accept ε, ε  S$ ε, $ εε, $ ε (,(  ε ),)  ε ε,S  SS ε,S  (S) ε,S  () q loop ()S)$()S)$ (

Example Read (()()) q start q accept ε, ε  S$ ε, $ εε, $ ε (,(  ε ),)  ε ε,S  SS ε,S  (S) ε,S  () q loop )S)$)S)$ ((

Example Read (()()) q start q accept ε, ε  S$ ε, $ εε, $ ε (,(  ε ),)  ε ε,S  SS ε,S  (S) ε,S  () q loop S)$S)$ (()

Example Read (()()) q start q accept ε, ε  S$ ε, $ εε, $ ε (,(  ε ),)  ε ε,S  SS ε,S  (S) ε,S  () q loop ())$())$ (()

Example Read (()()) q start q accept ε, ε  S$ ε, $ εε, $ ε (,(  ε ),)  ε ε,S  SS ε,S  (S) ε,S  () q loop ))$))$ (()(

Example Read (()()) q start q accept ε, ε  S$ ε, $ εε, $ ε (,(  ε ),)  ε ε,S  SS ε,S  (S) ε,S  () q loop )$)$ (()()

Example Read (()()) q start q accept ε, ε  S$ ε, $ εε, $ ε (,(  ε ),)  ε ε,S  SS ε,S  (S) ε,S  () q loop $ (()())

Example Read (()()) q start ε, ε  S$ ε, $ εε, $ ε (,(  ε ),)  ε ε,S  SS ε,S  (S) ε,S  () q loop (()()) q accept

More Examples L= {a i b j c k, i=j or j=k>, and i,j,k>=0}. L= {ww R | w in {0,1}* }

Differences between PDA’s and NFA’s Transitions read one symbol of the string and push a string onto or pop a symbol off of the stack Stack alphabet is not necessarily the same as the alphabet for the language  e.g., $ marks bottom of stack in previous (0 n 1 n ) example

Instantaneous descriptions

Equivalence of pda and cfg

Equivalence of PDA’s and CFG’s Theorem: A language is context free if and only if some pushdown automaton accepts it by e.s. Proved in two lemmas – one for the “if” direction and one for the “only if” direction We will only do the “only if” step – i.e., show that every context-free language has an associated PDA

CFG’s are recognized by PDA’s Lemma: If a language is context free, then some pushdown automaton accepts it by emp.st. Proof idea: Construct a PDA following CFG rules

Constructing the PDA You can read any symbol in  when that symbol is at the top of the stack  Transitions of the form a,a  ε The rules will be pushed onto the stack – when a variable A is on top of the stack and there is a rule A  w, you pop A and push w You accept only if the input is exhausted and the stack is empty

Idea of PDA construction for A  xBz State control a b AtAt State control a b xBztxBzt

Given G build PDA

Deterministic PDA