CIS Automata and Formal Languages – Pei Wang

Slides:



Advertisements
Similar presentations
Chapter 5 Pushdown Automata
Advertisements

1 Pushdown Automata (PDA) Informally: –A PDA is an NFA-ε with a stack. –Transitions are modified to accommodate stack operations. Questions: –What is a.
C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
Pushdown Automata (PDA)
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture7: PushDown Automata (Part 1) Prof. Amos Israeli.
1 … NPDAs continued. 2 Pushing Strings Input symbol Pop symbol Push string.
Courtesy Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
CS 310 – Fall 2006 Pacific University CS310 Pushdown Automata Sections: 2.2 page 109 October 9, 2006.
Fall 2006Costas Busch - RPI1 Pushdown Automata PDAs.
January 14, 2015CS21 Lecture 51 CS21 Decidability and Tractability Lecture 5 January 14, 2015.
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.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen University 2010.
Pushdown Automata.
Pushdown Automata CS 130: Theory of Computation HMU textbook, Chap 6.
Pushdown Automata (PDAs)
Definition Moves of the PDA Languages of the PDA Deterministic PDA’s Pushdown Automata 11.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 6 Mälardalen University 2010.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Formal Languages, Automata and Models of Computation
1 Chapter 6 Pushdown automata Sagrada Familia ( 聖家 堂 ), Barcelona, Spain.
Grammar Set of variables Set of terminal symbols Start variable Set of Production rules.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen University 2011.
CS 154 Formal Languages and Computability March 15 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
Pushdown Automata - like NFA-  but also has a stack - transition takes the current state, the current input symbol, and the top-of-the-stack symbol (which.
6. Pushdown Automata CIS Automata and Formal Languages – Pei Wang.
5. Context-Free Grammars and Languages
Formal Languages, Automata and Models of Computation
CIS Automata and Formal Languages – Pei Wang
Pushdown Automata.
Theory of Computation Pushdown Automata pda Lecture #10.
Lecture 14 Push Down Automata (PDA)
Deterministic FA/ PDA Sequential Machine Theory Prof. K. J. Hintz
NPDAs Accept Context-Free Languages
CSE 105 theory of computation
Pushdown Automata (PDA). Part 2
Pushdown Automata PDAs
Push-down Automata Section 3.3 Wed, Oct 27, 2004.
Pushdown Automata PDAs
Pushdown Automata PDAs
PDAs Accept Context-Free Languages
Pushdown Automata PDAs
PUSHDOWN AUTOMATA. PUSHDOWN AUTOMATA Hierarchy of languages Regular Languages  Finite State Machines, Regular Expression Context Free Languages 
Chapter 7 PUSHDOWN AUTOMATA.
AUTOMATA THEORY VI.
Pushdown Automata (PDA)
Pushdown Automata (PDA). Part 3
NPDAs Accept Context-Free Languages
Pushdown Automata Reading: Chapter 6.
Deterministic Finite Automata And Regular Languages Prof. Busch - LSU.
5. Context-Free Grammars and Languages
Intro to Data Structures
8. Introduction to Turing Machines
فصل دوم Context-Free Languages
Definition Moves of the PDA Languages of the PDA Deterministic PDA’s
CSCE 531 Compiler Construction
Pushdown automata a_introduction.htm.
Definition Moves of the PDA Languages of the PDA Deterministic PDA’s
Chapter 2 Context-Free Language - 01
Principles of Computing – UFCFA3-30-1
… NPDAs continued.
CSE 105 theory of computation
Pushdown automata The Chinese University of Hong Kong Fall 2011
Teori Bahasa dan Automata Lecture 10: Push Down Automata
CSE 105 theory of computation
CSE 105 theory of computation
CSE 105 theory of computation
Presentation transcript:

CIS 5513 - Automata and Formal Languages – Pei Wang 6. Pushdown Automata CIS 5513 - Automata and Formal Languages – Pei Wang

Pushdown automata: idea Context-Free Languages can be accepted by pushdown automata A pushdown automaton is an ɛ-NFA with a stack with unlimited capacity Its transition function also takes the top of the stack into account, and may change the top item in the stack It accepts at a final state or an empty stack

Pushdown automata: definition A pushdown automaton (PDA) P = (Q, Σ, Γ, δ, q0, Z0, F) where Γ (Gamma): A finite stack alphabet δ: Q×(Σ{ε})×Γ → 2Q×Γ*, a transition function that specifies the set of possible next state and the new content at the top of the stack Z0  Γ, the start symbol in stack The other components are like in an ɛ-NFA

Example: transition table A PDA for the binary language {wwr}: P = ({q0,q1,q2}, {0, 1}, {Z0,0,1}, δ, q0, Z0, {q2}) 1. δ(q0, 0, Z0) = {(q0, 0Z0)}; δ(q0, 1, Z0) = {(q0, 1Z0)} 2. δ(q0, 0, 0) = {(q0, 00)}; δ(q0, 0, 1) = {(q0, 01)}; δ(q0, 1, 0) = {(q0, 10)}; δ(q0, 1, 1) = {(q0, 11)} 3. δ(q0, ɛ, Z0) = {(q1, Z0)}; δ(q0, ɛ, 0) = {(q1, 0)}; δ(q0, ɛ, 1) = {(q1, 1)} 4. δ(q1, 0, 0) = {(q1, ɛ)}; δ(q1, 1, 1) = {(q1, ɛ)} 5. δ(q1, ɛ, Z0) = {(q2, Z0)}

Example: transition graph

Instantaneous descriptions of PDA The configuration, or instantaneous description (ID), of a PDA: (q, w, r), where q is the state, w is the remaining input, and r is the stack contents Here “state” only specifies the “control unit”, not the stored “data” in stack If the value of δ(q, a, X) contains (p, α), then the ID transition is (q, aw, Xβ) ˫ (p, w, αβ), for arbitrary w and β

ID transitions: an example

Properties of ID transitions ID transition with multiple moves is shown as ˫* Symbols may be added or removed to input or stack in ID transitions

Exercise 6.1.1 Solution

Two types of acceptance A PDA can define a language in two ways

From Empty Stack to Final State PF can be obtained by adding an ɛ-transition to a final state whenever the stack in PN is empty, with the help of a new stack-symbol below Z0

From Final State to Empty Stack PN can be obtained by popping out all stack symbols in final states in PF, with the help of a new stack-symbol below Z0

6.2.1(a): Design a PDA to accept {0n1n | n ≥ 1} Exercises for Section 6.2 6.2.1(a): Design a PDA to accept {0n1n | n ≥ 1} 6.2.2(a): Design a PDA to accept {aibjck | i = j or j = k} Solutions: http://infolab.stanford.edu/~ullman/ialcsols/sol6.html#sol62

CFG to PDA From a given CFG G = (V, T, Q, S), a PN = ({q},T, VT, , q, S) can accept L(G) by simulating the leftmost derivation to expand the symbols in stack to match the input When PN is in ID (q, y, Aα) where A is a variable and there is a rule A→β in Q, the next ID can be (q, y, βα). Remove the common prefix of βα and y. Repeat until the stack is empty

CFG to PDA: example

PDA to CFG:simple case If a PDA is P = ({q}, Σ, Γ, δ, q, Z), the equivalent CFG G = (Γ{S}, Σ, R, S), where R contains S → Z, and for each (q, Y1Y2…Yk) in δ(q, a, X), R contains X → aY1Y2…Yk, where k ≥ 0, and Yi can be a variable, a terminal, or ε

PDA to CFG: general case Use a grammar variable [pXq] to represent the state change from p to q for the popping out of a stack symbol X

PDA to CFG (cont.)

PDA to CFG: example 6.10: δ(q, i, Z) = {(q, ZZ)}; δ(q, e, Z) = {(q, ε)}

PDA to CFG: example (2)

PDA to CFG: example (3)

Exercises for Section 6.3 Solutions: http://infolab.stanford.edu/~ullman/ialcsols/sol6.html#sol63

Deterministic pushdown automata A PDA is deterministic (DPDA), if Each δ(q, a, X) has at most one element If δ(q, a, X) is nonempty, then δ(q, ɛ, X) must be empty Lwcwr = {wcwR} with a marker c

PDA, DPDA, and DFA The set of language accepted by DPDA is a subset of CFL, and a super set of regular language, so the capability of DPDA is between those of PDA and DFA DPDA accept all regular languages, but only the context-free languages that have unambiguous CFG