Chapter 14: Pushdown Automata

Similar documents
Chapter 18: Decidability

CS5371 Theory of Computation. Lecture 8: Automata Theory VI (PDA, PDA = CFG)

Pushdown Automata. A PDA is an FA together with a stack.

ONE-STACK AUTOMATA AS ACCEPTORS OF CONTEXT-FREE LANGUAGES *

PDA s. and Formal Languages. Automata Theory CS 573. Outline of equivalence of PDA s and CFG s. (see Theorem 5.3)

Outline. Language Hierarchy

CSCI 340: Computational Models. Turing Machines. Department of Computer Science

CSE 105 THEORY OF COMPUTATION

Theory of Computations Spring 2016 Practice Final Exam Solutions

CS402 - Theory of Automata Glossary By

Decidable Problems. We examine the problems for which there is an algorithm.

Turing Machines. A transducer is a finite state machine (FST) whose output is a string and not just accept or reject.

Closure Properties of CFLs; Introducing TMs. CS154 Chris Pollett Apr 9, 2007.

(a) R=01[((10)*+111)*+0]*1 (b) ((01+10)*00)*. [8+8] 4. (a) Find the left most and right most derivations for the word abba in the grammar

Theory of Languages and Automata

Definition 2.8: A CFG is in Chomsky normal form if every rule. only appear on the left-hand side, we allow the rule S ǫ.

R10 SET a) Construct a DFA that accepts an identifier of a C programming language. b) Differentiate between NFA and DFA?

CSE 105 THEORY OF COMPUTATION

JNTUWORLD. Code No: R

CT32 COMPUTER NETWORKS DEC 2015

QUESTION BANK. Unit 1. Introduction to Finite Automata

where is the transition function, Pushdown Automata is the set of accept states. is the start state, and is the set of states, is the input alphabet,

Last lecture CMSC330. This lecture. Finite Automata: States. Finite Automata. Implementing Regular Expressions. Languages. Regular expressions

Introduction to Computers & Programming


A Characterization of the Chomsky Hierarchy by String Turing Machines

ECS 120 Lesson 16 Turing Machines, Pt. 2

LL(1) predictive parsing

Skyup's Media. PART-B 2) Construct a Mealy machine which is equivalent to the Moore machine given in table.

CS402 Theory of Automata Solved Subjective From Midterm Papers. MIDTERM SPRING 2012 CS402 Theory of Automata

TAFL 1 (ECS-403) Unit- V. 5.1 Turing Machine. 5.2 TM as computer of Integer Function

I have read and understand all of the instructions below, and I will obey the Academic Honor Code.

From Theorem 8.5, page 223, we have that the intersection of a context-free language with a regular language is context-free. Therefore, the language

UNIT I PART A PART B

CS402 - Theory of Automata FAQs By

Computer Sciences Department

Midterm Exam II CIS 341: Foundations of Computer Science II Spring 2006, day section Prof. Marvin K. Nakayama

Multiple Choice Questions

Derivations of a CFG. MACM 300 Formal Languages and Automata. Context-free Grammars. Derivations and parse trees

1 Parsing (25 pts, 5 each)

1. (10 points) Draw the state diagram of the DFA that recognizes the language over Σ = {0, 1}

Equivalence of NTMs and TMs

Actually talking about Turing machines this time

pp Variants of Turing Machines (Sec. 3.2)

KHALID PERVEZ (MBA+MCS) CHICHAWATNI

CSE 105 THEORY OF COMPUTATION

Theory of Programming Languages COMP360

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016

CISC 4090 Theory of Computation

Theory of Computations Spring 2016 Practice Final

Regular Languages (14 points) Solution: Problem 1 (6 points) Minimize the following automaton M. Show that the resulting DFA is minimal.

PS3 - Comments. Describe precisely the language accepted by this nondeterministic PDA.

Theory of Computation, Homework 3 Sample Solution

Parsing. For a given CFG G, parsing a string w is to check if w L(G) and, if it is, to find a sequence of production rules which derive w.

Specifying Syntax COMP360

Turing Machine Languages

1. Draw the state graphs for the finite automata which accept sets of strings composed of zeros and ones which:

Variants of Turing Machines

Theory of Computation

A Note on the Succinctness of Descriptions of Deterministic Languages

Theory of Computation p.1/?? Theory of Computation p.2/?? A Turing machine can do everything that any computing

LLparse and LRparse: Visual and Interactive Tools for Parsing

CS 44 Exam #2 February 14, 2001

Theory Bridge Exam Example Questions Version of June 6, 2008

Eliminating the Storage Tape in Reachability Constructions

1. [5 points each] True or False. If the question is currently open, write O or Open.

Finite automata. We have looked at using Lex to build a scanner on the basis of regular expressions.

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

Theory of Computation Dr. Weiss Extra Practice Exam Solutions

University of Nevada, Las Vegas Computer Science 456/656 Fall 2016

CS210 THEORY OF COMPUTATION QUESTION BANK PART -A UNIT- I

Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and

CSCI 3130: Formal Languages and Automata Theory Lecture 16 The Chinese University of Hong Kong, Fall 2010

Context Free Languages and Pushdown Automata

Name: CS 341 Practice Final Exam. 1 a 20 b 20 c 20 d 20 e 20 f 20 g Total 207

Decision Properties for Context-free Languages

Optimizing Finite Automata

Material from Recitation 1

Prediction of Infinite Words with Automata

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

CS21 Decidability and Tractability

20 Models Of Computation

LL Parsing, LR Parsing, Complexity, and Automata

Formal languages and computation models

T.E. (Computer Engineering) (Semester I) Examination, 2013 THEORY OF COMPUTATION (2008 Course)

The Big Picture. Chapter 3

Turning Automata Theory into a Hands-on Course

QUESTION BANK. Formal Languages and Automata Theory(10CS56)

LL(1) predictive parsing

MIT Specifying Languages with Regular Expressions and Context-Free Grammars. Martin Rinard Massachusetts Institute of Technology


AUBER (Models of Computation, Languages and Automata) EXERCISES

Formal Grammars and Abstract Machines. Sahar Al Seesi

CS/B.Tech/CSE/IT/EVEN/SEM-4/CS-402/ ItIauIafIaAblll~AladUnrtel1ity

CMPSCI 250: Introduction to Computation. Lecture 20: Deterministic and Nondeterministic Finite Automata David Mix Barrington 16 April 2013

Final Course Review. Reading: Chapters 1-9

CS311 / MATH352 - AUTOMATA AND COMPLEXITY THEORY

CSC-461 Exam #2 April 16, 2014

Homework. Context Free Languages. Before We Start. Announcements. Plan for today. Languages. Any questions? Recall. 1st half. 2nd half.

Automata & languages. A primer on the Theory of Computation. The imitation game (2014) Benedict Cumberbatch Alan Turing ( ) Laurent Vanbever

Transcription:

Chapter 14: Pushdown Automata Peter Cappello Department of Computer Science University of California, Santa Barbara Santa Barbara, CA 93106 cappello@cs.ucsb.edu The corresponding textbook chapter should be read before attending this lecture. These notes are not intended to be complete. They are supplemented with figures, and other material that arises during the lecture period in response to questions. Based on Theory of Computing, 2nd Ed., D. Cohen, John Wiley & Sons, Inc. 1

A New Format for Finite Automata We give an alternate format for describing FA: The finite sequence of symbols to be read, the input word, resides on an input tape, which extends infinitely to the right, and which is divided into infinitely many cells. The 1st symbol is in the leftmost cell. The 2nd symbol is in the cell to the right, and so on. All cells beyond those that have an input symbol contain a blank, denoted by. The machine starts in a position ready to read the leftmost symbol on the input tape. 2

After it reads this symbol, it moves in position (1 cell to the right) to read the next symbol. Give a picture of an input tape with the word abba. We introduce the following 3 new diagrammatic symbols: Draw the START, ACCEPT, and REJECT symbols. A START is like the - state, connected to a state by a Λ-edge. An ACCEPT is a dead-end (once entered, never exited) final state. A REJECT is a dead-end non-final state. Accept and Reject states are called halt states. We introduce the READ symbol. Draw a picture of this. It denotes reading 1 symbol on the input tape (and positioning to read the next symbol). 3

Depict 2 examples: an FA that accepts (a + b) a. an FA that accepts (a + b) aa(a + b). 4

Adding a Stack Adding a stack to our finite automaton results machine is called a pushdown automaton (PDA). It has: a PUSH s operation Draw a picture of this. a POP operation. Draw a picture of this. Popping the empty stack yields a. Example: What language does the following PDA accept? The alphabet of stack symbols need not be the input alphabet. A PDA with only 1 arc for each symbol (input and stack) is a deterministic PDA (DPDA). 5

If a PDA has either a READ or POP state with > 1 arc for some symbol, it is a non-deterministic PDA (NPDA). We may omit arcs leading out of a READ or POP state. When such an arc is omitted, it means that the machine crashes (i.e., goes to a REJECT state). Example: Here is a DPDA for: X centered palindromes = {wxw R w (a + b) }, where w R means the reverse of w, and the input alphabet = {a, b, X}. 6

Example: Here is an NPDA for: Odd length palindromes = {w(a + b)w R w (a + b) }, where w R means the reverse of w. The language above is contained in the language of palindromes. Example: Here is an NPDA for: Even length palindromes = {ww R w (a + b) }, where w R means the reverse of w. The language above is contained in the language of palindromes. 7

Defining the PDA Definition A pushdown automaton, PDA, is a collection of 8 things: 1. An alphabet Σ of input symbols. 2. An input TAPE (infinite in 1 direction). The input word starts in the leftmost cell. The rest of the TAPE is blank. 3. An alphabet Γ of stack symbols. 4. A stack (infinite in 1 direction), initially blank. 5. One START state that has only out-edges. 6. Halt states (ACCEPT & REJECT). They only have in-edges. 8

7. Finitely many non-branching PUSH states. 8. Finitely many branching states of 2 kinds: States that READ the next input symbol, with out-edges labelled with the blank character,, and elements of Σ. There need not be an arc for each such symbol. States that POP the stack, with out-edges labelled with the blank character,, and elements of Γ. There need not be an arc for each such symbol. All the states above form a connected directed graph. To run the PDA on an input: Beginning from the START state, follow unlabelled edges and labelled edges that apply to produce a path through the graph. This path ends in either: 9

a halt state a crash when there is no edge corresponding to the symbol read/popped. An input with some path to an ACCEPT is accepted. The set of strings accepted by a PDA is called the language accepted by the PDA, or the language recognized by the PDA. 10

Example Consider the language generated by the CFG S S + S S S 4. The following PDA accepts this language. Draw on board. 11

Theorem For every regular language L, there is a PDA that accepts it. Proof The notation that we introduced without the stack, is an alternate notation for finite automata. Thus, it is capable of expressing any finite automaton. 12

Theorem Given a PDA A,there is a PDA B that accepts the same language. Moreover, when an ACCEPT state in B is entered, all the input has been read and stack is empty. Proof Replace each of A s ACCEPT states with the following routine: The arcs into the A s ACCEPT state go into a new READ state in B. This READ state s out-edges are self-loops, except on. The arc is to a POP state. The POP state out-edges are self-loops, except on. The arc is to an ACCEPT state. If we replace A s ACCEPT states with this sequence, when the new AC- CEPT state is reached, all the input has been read and the stack is empty. 13