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,

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

A Characterization of the Chomsky Hierarchy by String Turing Machines

Chapter 14: Pushdown Automata

Universal Turing Machine Chomsky Hierarchy Decidability Reducibility Uncomputable Functions Rice s Theorem Decidability Continued

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

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

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

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 ǫ.

CSE 105 THEORY OF COMPUTATION

CT32 COMPUTER NETWORKS DEC 2015

Theory of Computation, Homework 3 Sample Solution

Formal Languages and Automata

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

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

Finite Automata. Dr. Nadeem Akhtar. Assistant Professor Department of Computer Science & IT The Islamia University of Bahawalpur

Introduction to Computers & Programming

Bottom-Up Parsing. Lecture 11-12

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

Theory of Computations Spring 2016 Practice Final Exam Solutions

Quiz 1: Solutions J/18.400J: Automata, Computability and Complexity. Nati Srebro, Susan Hohenberger

We can create PDAs with multiple stacks. At each step we look at the current state, the current input symbol, and the top of each stack.


A Note on the Succinctness of Descriptions of Deterministic Languages

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

Nested Words. A model of linear and hierarchical structure in data. Examples of such data

CS402 - Theory of Automata Glossary By

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

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

Regular Languages and Regular Expressions

Theory of Languages and Automata

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

MIT Specifying Languages with Regular Expressions and Context-Free Grammars

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

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

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

Computer Sciences Department

Limits of Computation p.1/?? Limits of Computation p.2/??

UNIT I PART A PART B

Final Course Review. Reading: Chapters 1-9

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

Normal Forms for CFG s. Eliminating Useless Variables Removing Epsilon Removing Unit Productions Chomsky Normal Form

Turing Machine Languages

Formal Grammars and Abstract Machines. Sahar Al Seesi

NFAs and Myhill-Nerode. CS154 Chris Pollett Feb. 22, 2006.

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

Interpreter. Scanner. Parser. Tree Walker. read. request token. send token. send AST I/O. Console

Languages and Compilers

ECS 120 Lesson 16 Turing Machines, Pt. 2

Parsing. source code. while (k<=n) {sum = sum+k; k=k+1;}

Chapter Seven: Regular Expressions

The Generalized Star-Height Problem

Context Free Grammars. CS154 Chris Pollett Mar 1, 2006.

Multiple Choice Questions

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Course Project 2 Regular Expressions

Dr. D.M. Akbar Hussain

Theory of Computation Dr. Weiss Extra Practice Exam Solutions

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

Turing Machines, continued

Theory Bridge Exam Example Questions Version of June 6, 2008

Lexical Analysis. Prof. James L. Frankel Harvard University

Theory of Computation

COP 3402 Systems Software Syntax Analysis (Parser)

Model checking pushdown systems

Theory of Programming Languages COMP360

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

Implementation of Lexical Analysis

Introduction to Automata Theory. BİL405 - Automata Theory and Formal Languages 1

Implementation of Lexical Analysis

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

Lecture Bottom-Up Parsing

KEY. A 1. The action of a grammar when a derivation can be found for a sentence. Y 2. program written in a High Level Language

QUESTION BANK. Unit 1. Introduction to Finite Automata

DHANALAKSHMI SRINIVASAN INSTITUTE OF RESEARCH AND TECHNOLOGY SIRUVACHUR, PERAMBALUR DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Converting a DFA to a Regular Expression JP

CS 44 Exam #2 February 14, 2001

Context-Free Languages and Pushdown Automata

Formal Languages. Formal Languages

Lecture 7: Primitive Recursion is Turing Computable. Michael Beeson

COMP 330 Autumn 2018 McGill University

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

Compilation 2012 Context-Free Languages Parsers and Scanners. Jan Midtgaard Michael I. Schwartzbach Aarhus University

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

LR Parsing LALR Parser Generators

In One Slide. Outline. LR Parsing. Table Construction

Theory of Computations Spring 2016 Practice Final

Outline. Language Hierarchy

Syntax Analysis Part I

t!1; R 0! 1; R q HALT

Ambiguous Grammars and Compactification

Lecture 7: Deterministic Bottom-Up Parsing

Introduction to Lexing and Parsing

CS143 Handout 20 Summer 2012 July 18 th, 2012 Practice CS143 Midterm Exam. (signed)

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

MIT Parse Table Construction. Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology

Decision Properties for Context-free Languages

Formal Languages and Compilers Lecture IV: Regular Languages and Finite. Finite Automata

Answer All Questions. All Questions Carry Equal Marks. Time: 20 Min. Marks: 10.

Bottom-Up Parsing. Lecture 11-12

Specifying Syntax COMP360

Transcription:

!# #! + Pushdown utomata CS5 ecture Pushdown utomata where pushdown automaton is a 6tuple are finite sets is the set of states is the input alphabet is the stack alphabet is the transition function is the start state 5 is the set of accept states 6 CS5 ecture Pushdown utomata cont d t each computational step a PD does the following nondeterministically decides whether to read the next input symbol the current stack symbol; for input symbol stack symbol the choices are ; if the input or stack are empty there are fewer than choices; if it reads moves past then if from the stack; if the choice is it pops it nondeterministically selects the next state a symbol to be put on the stack according to the transition function It halts when either i there is no next move or ii no input symbols are left the current state is an accept state CS5 ecture Pushdown utomata cont d can be represented if accepts a word there exist satisfying the following conditions with as + * where ' for some + ere the stack is read from top to bottom or left to right CS5 ecture

PD Example / Design Idea Use a special symbol to mark the bottom of the stack Using wouldn t work because is always there First put onto the stack all the s preceding the s Then try to match the stacked s with the s is the top The input string is in if only if the bottom symbol when all the input symbols have been read CS5 ecture 5 Example cont d is the initial state 7 7 6 5 We use to place the on the stack to read s push them onto the stack react to the first to read s pop s from the stack react to the by going to accept state s a diagram 5 6 7 CS5 ecture 6 Example cont d s a transition table where blank means empty set Input Stack 5 6 5 5 7 6 6 denote the configuration in which the the stack word is the remaining input is et state is 5 is accepted by a path 6 5 5 5 7 6 6 CS5 ecture 7 PD Example s s is the initial state has an eual number of / 7 6 5 7 6 6 5 5 5 6 ere are omitted State is used to place on the stack is used to pop stack symbols matching a complementary input symbol to recognize when we re done is used to push unmatched s onto the stack to push unmatched s onto the stack 5 6 CS5 ecture

9 PD Example cont d 5 Example 6 6 7 CS5 ecture 9 PDs Recognize CFs Theorem Each contextfree language is recognized by a PD be produced by a Chomsky normal form grammar Proof et ; IDE Construct a PD that performs leftmost derivations step of a derivation using is implemented by popping the lefth side pushing the righth side of the rule onto the stack step using is implemented by popping the lefth side comparing the righth side to the input symbol expending that symbol CS5 ecture PD Recognize CFs cont d It has one accept state stack alphabet is s input alphabet is on the stack repeats the following until pushes a then an it halts enters the accept state If pops a stack symbol halts nondeterministically chooses a production rule If takes no action back to step pushes a then for some variables onto the stack If then a then ; if reads the next input symbol If halts CS5 ecture if S in G S S C if C in G a if a in G CS5 ecture

C C J K CFs Capture PD Theorem Every language recognized by PD is context free Proof et * be recognized by a PD We can assume has a uniue final state when it enters the state the stack is empty ** In a single move CFs Capture PD cont d s to ** divide each state involving push pop into two states one for push only the other for pop only Idea for ensuring * Modify a new stack symbol a new initial state a cleanup state either pops or pushes but not both to create a new PD to mark bottom of stack for putting on the stack for clearing the stack a new uniue accepting state which has CS5 ecture CFs Capture PD cont d The only permissible action in is to put one on the stack without reading an input symbol go to the old initial state In each state in the action of is the same except that there is an transition from each former accepting state to The goal in state is to remove stack symbols one after another to enter upon observing a becomes a pair of moves in followed by CS5 ecture D in D ab c r becomes r ab c r CS5 ecture 5 CFs Capture PD cont d satisfies * ** Now suppose is the uniue final state of / FG E GI Construct a CFG where is the initial state of Key idea For any states is a variable generating the strings that can take from to while preserving the stack Then by taking as the start state as the accept state we have a variable that generates precisely the strings accepted by thus can serve as start symbol FG CS5 ecture 6

P C OM CFs Capture PD cont d corresponds to the set of all strings FG More precisely the variable under the following conditions expended by ends with state starts with the stack height is always at least For some at the start as well as at the end precisely CS5 ecture 7 Production rules F F M G FM FG N C FG then N C N if x y p r p r b d x cd s push pop p p rs stack preserving transitions pr r b c x x y CS5 ecture CFs Regular anguages First proof ny F can be viewed as a PD that never pops or pushes the stack Second proof uild a CFG for a F where a for p we use P aq for r we use R CS5 ecture 9 Properties of ContextFree anguages Theorem The contextfree languages are closed under union concatenation star be the Proof et be the start symbols of two CFGs et new start symbol of the new CFG we are creating 5 works for union 5 / dding works for concatenation 5 dding works for star dding This also shows how regular expressions can be converted to euivalent CFGs providing a rd proof that regular languages are CFs CS5 ecture