C6.2 Push-Down Automata

Similar documents
C2.1 Regular Grammars

C2.1 Regular Grammars

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Foundations of Informatics: a Bridging Course

Einführung in die Computerlinguistik

Formal Languages and Automata

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,

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

Theory of Computer Science

C1.1 Introduction. Theory of Computer Science. Theory of Computer Science. C1.1 Introduction. C1.2 Alphabets and Formal Languages. C1.

Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. The stack

Push-down Automata = FA + Stack

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.

Nondeterministic Finite Automata

Pushdown Automata. Reading: Chapter 6

Automata Theory (2A) Young Won Lim 5/31/18

Chapter 1. Formal Definition and View. Lecture Formal Pushdown Automata on the 28th April 2009

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Theory of Computer Science

Outline. CS21 Decidability and Tractability. Machine view of FA. Machine view of FA. Machine view of FA. Machine view of FA.

Introduction to Formal Languages, Automata and Computability p.1/42

Computability and Complexity

C4.1 Closure Properties

CFGs and PDAs are Equivalent. We provide algorithms to convert a CFG to a PDA and vice versa.

DM17. Beregnelighed. Jacob Aae Mikkelsen

Pushdown Automata. We have seen examples of context-free languages that are not regular, and hence can not be recognized by finite automata.

Automata Theory - Quiz II (Solutions)

Computational Models - Lecture 5 1

Mildly Context-Sensitive Grammar Formalisms: Embedded Push-Down Automata

UNIT-VI PUSHDOWN AUTOMATA

3.13. PUSHDOWN AUTOMATA Pushdown Automata

Undecidable Problems and Reducibility

Harvard CS 121 and CSCI E-207 Lecture 10: Ambiguity, Pushdown Automata

Theory of Computation

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen

5 Context-Free Languages

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs

Languages. Non deterministic finite automata with ε transitions. First there was the DFA. Finite Automata. Non-Deterministic Finite Automata (NFA)

CPS 220 Theory of Computation Pushdown Automata (PDA)

Part I: Definitions and Properties

CSE 105 THEORY OF COMPUTATION

Chapter Five: Nondeterministic Finite Automata

Computability and Complexity

Theory of Computation Turing Machine and Pushdown Automata

Theory of Computation

Definition: A grammar G = (V, T, P,S) is a context free grammar (cfg) if all productions in P have the form A x where

Computational Models - Lecture 4

60-354, Theory of Computation Fall Asish Mukhopadhyay School of Computer Science University of Windsor

Pushdown Automata (2015/11/23)

CISC4090: Theory of Computation

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Theory of Computation (IV) Yijia Chen Fudan University

Pushdown Automata (Pre Lecture)

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018

(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},

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

Pushdown Automata. Notes on Automata and Theory of Computation. Chia-Ping Chen

Formal Definition of a Finite Automaton. August 26, 2013

CSE 105 THEORY OF COMPUTATION

Classes and conversions

Context-Free Languages

Deterministic Finite Automata. Non deterministic finite automata. Non-Deterministic Finite Automata (NFA) Non-Deterministic Finite Automata (NFA)

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

Theory of Computation

Turing Machines A Turing Machine is a 7-tuple, (Q, Σ, Γ, δ, q0, qaccept, qreject), where Q, Σ, Γ are all finite

October 6, Equivalence of Pushdown Automata with Context-Free Gramm

Pushdown Automata. Chapter 12

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

MA/CSSE 474 Theory of Computation

The Post Correspondence Problem

CSE 105 THEORY OF COMPUTATION

Accept or reject. Stack

Testing Emptiness of a CFL. Testing Finiteness of a CFL. Testing Membership in a CFL. CYK Algorithm

Lecture 17: Language Recognition

Lecture 3: Nondeterministic Finite Automata

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

SCHEME FOR INTERNAL ASSESSMENT TEST 3

Automata and Languages

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CDM Parsing and Decidability

Grammars and Context Free Languages

NPDA, CFG equivalence

Homework. Context Free Languages. Announcements. Before We Start. Languages. Plan for today. Final Exam Dates have been announced.

PARALLEL COMMUNICATING FLIP PUSHDOWN AUTOMATA SYSTEMS COMMUNICATING BY STACKS

CSE 105 THEORY OF COMPUTATION

Recitation 4: Converting Grammars to Chomsky Normal Form, Simulation of Context Free Languages with Push-Down Automata, Semirings

What languages are Turing-decidable? What languages are not Turing-decidable? Is there a language that isn t even Turingrecognizable?

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Decidable and undecidable languages

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Grammars and Context Free Languages

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

Let us first give some intuitive idea about a state of a system and state transitions before describing finite automata.

Final exam study sheet for CS3719 Turing machines and decidability.

Properties of Context-Free Languages

CSE 211. Pushdown Automata. CSE 211 (Theory of Computation) Atif Hasan Rahman

Languages, regular languages, finite automata

Transcription:

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 5, 2017 C6.1 Motivation C6.2 Push-Down Automata C6.3 PDAs vs. Context-free Languages C6.4 Summary Malte Helmert (University of Basel) Theory of Computer Science April 5, 2017 1 / 23 Malte Helmert (University of Basel) Theory of Computer Science April 5, 2017 2 / 23 C6. Context-free Languages: Push-down Automata Motivation C6. Context-free Languages: Push-down Automata Motivation Limitations of Finite Automata 0,1 C6.1 Motivation q 0 0 q 0 1 q 2 Language L is regular. There is a finite automaton that accepts L. What information can a finite automaton store about the already read part of the word? Infinite memory would be required for L = {x 1 x 2... x n x n... x 2 x 1 n > 0, x i {a, b}}. therefore: extension of the automata model with memory Malte Helmert (University of Basel) Theory of Computer Science April 5, 2017 3 / 23 Malte Helmert (University of Basel) Theory of Computer Science April 5, 2017 4 / 23

C6. Context-free Languages: Push-down Automata Motivation Stack C6. Context-free Languages: Push-down Automata Motivation Push-down Automata: Visually A stack is a data structure following the last-in-first-out (LIFO) principle supporting the following operations: push: puts an object on top of the stack pop: removes the object at the top of the stack peek: returns the top object without removing it German: Keller, Stapel Push Pop Input tape I n p u t Read head Push-down automaton Stack access Stack German: Kellerautomat, Eingabeband, Lesekopf, Kellerzugriff Malte Helmert (University of Basel) Theory of Computer Science April 5, 2017 5 / 23 Malte Helmert (University of Basel) Theory of Computer Science April 5, 2017 6 / 23 Push-down Automata: Definition Definition (Push-down Automaton) C6.2 Push-Down Automata A push-down automaton (PDA) is a 6-tuple M = Q, Σ, Γ, δ, q 0, # with Q finite set of states Σ the input alphabet Γ the stack alphabet δ : Q (Σ {ε}) Γ P f (Q Γ ) the transition function (where P f is the set of all finite subsets) q 0 Q the start state # Γ the bottommost stack symbol German: Kellerautomat, Eingabealphabet, Kelleralphabet, Überführungsfunktion Malte Helmert (University of Basel) Theory of Computer Science April 5, 2017 7 / 23 Malte Helmert (University of Basel) Theory of Computer Science April 5, 2017 8 / 23

Push-down Automata: Transition Function Push-down Automata: Example Let M = Q, Σ, Γ, δ, q 0, # be a push-down automaton. What is the Intuitive Meaning of the Transition Function δ? q, B 1... B k δ(q, a, A): If M is in state q, reads symbol a and has A as the topmost stack symbol, then M can transition to q in the next step while replacing A with B 1... B k (afterwards B 1 is the topmost stack symbol) a, A B 1... B k q q special case a = ε is allowed (spontaneous transition) a, A AA a, B AB a, # A# b, A BA b, B BB b, # B# q q M = {q, q }, {a, b}, {A, B, #}, δ, q, # with δ(q, a, A) = { q, AA, q, ε } δ(q, b, A) = { q, BA } δ(q, a, B) = { q, AB } ε, # ε δ(q, ε, A) = δ(q, b, B) = { q, BB, q, ε } δ(q, ε, B) = δ(q, a, #) = { q, A# } δ(q, b, #) = { q, B# } δ(q, ε, #) = δ(q, a, A) = { q, ε } δ(q, b, A) = δ(q, ε, A) = δ(q, a, B) = δ(q, b, B) = { q, ε } δ(q, ε, B) = δ(q, a, #) = δ(q, b, #) = δ(q, ε, #) = { q, ε } Malte Helmert (University of Basel) Theory of Computer Science April 5, 2017 9 / 23 Malte Helmert (University of Basel) Theory of Computer Science April 5, 2017 10 / 23 Push-down Automata: Configuration Push-down Automata: Steps Definition (Configuration of a Push-down Automaton) A configuration of a push-down automaton M = Q, Σ, Γ, δ, q 0, # is given by a triple c Q Σ Γ. German: Konfiguration Example I n p u t Definition (Transition/Step of a Push-down Automaton) We write c M c if a push-down automaton M = Q, Σ, Γ, δ, q 0, # can transition from configuration c to configuration c in one step. Exactly the following transitions are possible: q, a 1... a n, A 1... A m M q, a 2... a n, B 1... B k A 2... A m if q, B 1... B k δ(q, a 1, A 1 ) q Configuration q, ut, BAC#. q, a 1 a 2... a n, B 1... B k A 2... A m if q, B 1... B k δ(q, ε, A 1 ) German: Übergang If M is clear from context, we only write c c. Malte Helmert (University of Basel) Theory of Computer Science April 5, 2017 11 / 23 Malte Helmert (University of Basel) Theory of Computer Science April 5, 2017 12 / 23

Push-down Automata: Reachability of Configurations Push-down Automata: Recognized Words Definition (Reachable Configuration) Configuration c is reachable from configuration c in PDA M (c M c ) if there are configurations c 0,..., c n (n 0) where c 0 = c, c i M c i+1 for all i {0,..., n 1}, and c n = c. German: c ist in M von c erreichbar Definition (Recognized Word of a Push-down Automaton) PDA M = Q, Σ, Γ, δ, q 0, # recognizes the word w = a 1... a n iff the configuration q, ε, ε (word processed and stack empty) for some q Q is reachable from the start configuration q 0, w, #. M recognizes w iff q 0, w, # M q, ε, ε for some q Q. German: M erkennt w, Startkonfiguration Malte Helmert (University of Basel) Theory of Computer Science April 5, 2017 13 / 23 Malte Helmert (University of Basel) Theory of Computer Science April 5, 2017 14 / 23 Push-down Automata: Recognized Word Example Push-down Automata: Accepted Language a, A AA a, B AB a, # A# b, A BA b, B BB b, # B# q q ε, # ε Definition (Accepted Language of a Push-down Automaton) Let M be a push-down automaton with input alphabet Σ. The language accepted by M is defined as L(M) = {w Σ M recognizes w}. example: this PDA recognizes bbabbabb blackboard example: blackboard Malte Helmert (University of Basel) Theory of Computer Science April 5, 2017 15 / 23 Malte Helmert (University of Basel) Theory of Computer Science April 5, 2017 16 / 23

C6. Context-free Languages: Push-down Automata PDAs vs. Context-free Languages C6. Context-free Languages: Push-down Automata PDAs vs. Context-free Languages PDAs Accept Exactly the Context-free Languages C6.3 PDAs vs. Context-free Languages Theorem A language L is context-free if and only if L is accepted by a push-down automaton. Malte Helmert (University of Basel) Theory of Computer Science April 5, 2017 17 / 23 Malte Helmert (University of Basel) Theory of Computer Science April 5, 2017 18 / 23 C6. Context-free Languages: Push-down Automata PDAs vs. Context-free Languages PDAs Accept Exactly the Context-free Languages C6. Context-free Languages: Push-down Automata PDAs vs. Context-free Languages PDAs Accept Exactly the Context-free Languages Proof. : Let G = Σ, V, P, S be a context-free grammar for L. The push-down automaton M = {q}, Σ, V Σ, δ, q, S with the following δ accepts L: q, w δ(q, ε, A) for every rule A w P with w (V Σ). q, ε δ(q, a, a) for a Σ. Proof (continued). : omitted Because: x L(G) iff there is a derivation of the form S x in G iff there is a sequence of configurations of M with q, x, S q, ε, ε iff x L(M)... Malte Helmert (University of Basel) Theory of Computer Science April 5, 2017 19 / 23 Malte Helmert (University of Basel) Theory of Computer Science April 5, 2017 20 / 23

C6. Context-free Languages: Push-down Automata Summary C6. Context-free Languages: Push-down Automata Summary Summary C6.4 Summary Push-down automata (PDAs) extend NFAs with memory. PDAs accept not with end states but with an empty stack. The languages accepted by PDAs are exactly the context-free languages. Malte Helmert (University of Basel) Theory of Computer Science April 5, 2017 21 / 23 Malte Helmert (University of Basel) Theory of Computer Science April 5, 2017 22 / 23 C6. Context-free Languages: Push-down Automata Summary Further Topics on Context-free Languages and PDAs With the CYK-algorithm (Cocke, Younger and Kasami) it is possible to decide w L(G) in time O( w 3 ) for a grammar in Chomsky normal form and a word w. Deterministic push-down automata have the restriction δ(q, a, A) + δ(q, ε, A) 1 for all q Q, a Σ, A Γ. They accept with end states rather than empty stack. The languages accepted by deterministic PDAs are called deterministic context-free languages. They form a strict superset of the regular languages and a strict subset of the context-free languages. Malte Helmert (University of Basel) Theory of Computer Science April 5, 2017 23 / 23