Similar documents
Honors Class (Foundations of) Informatics. Tom Verhoeff. Department of Mathematics & Computer Science Software Engineering & Technology

Pushdown automata. Informatics 2A: Lecture 9. Alex Simpson. 3 October, School of Informatics University of Edinburgh als@inf.ed.ac.

Automata and Computability. Solutions to Exercises

Pushdown Automata. place the input head on the leftmost input symbol. while symbol read = b and pile contains discs advance head remove disc from pile

Regular Languages and Finite State Machines

Turing Machines: An Introduction

Model 2.4 Faculty member + student

Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

Automata Theory. Şubat 2006 Tuğrul Yılmaz Ankara Üniversitesi

Implementation of Recursively Enumerable Languages using Universal Turing Machine in JFLAP

Automata and Formal Languages

Introduction to Finite Automata

SRM UNIVERSITY FACULTY OF ENGINEERING & TECHNOLOGY SCHOOL OF COMPUTING DEPARTMENT OF SOFTWARE ENGINEERING COURSE PLAN

Reading 13 : Finite State Automata and Regular Expressions

Scanner. tokens scanner parser IR. source code. errors

3515ICT Theory of Computation Turing Machines

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, Class 4 Nancy Lynch

(IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems.

Pushdown Automata. International PhD School in Formal Languages and Applications Rovira i Virgili University Tarragona, Spain

24 Uses of Turing Machines

Regular Expressions and Automata using Haskell

Today s Agenda. Automata and Logic. Quiz 4 Temporal Logic. Introduction Buchi Automata Linear Time Logic Summary

Compiler Construction

Properties of Stabilizing Computations

Overview of E0222: Automata and Computability

Introduction to Automata Theory. Reading: Chapter 1

CSC4510 AUTOMATA 2.1 Finite Automata: Examples and D efinitions Definitions

The Halting Problem is Undecidable

Using Hands-On Visualizations to Teach Computer Science from Beginning Courses to Advanced Courses

T Reactive Systems: Introduction and Finite State Automata

Turing Machines, Part I

Increasing Interaction and Support in the Formal Languages and Automata Theory Course

Regular Languages and Finite Automata

Increasing Interaction and Support in the Formal Languages and Automata Theory Course

Lexical analysis FORMAL LANGUAGES AND COMPILERS. Floriano Scioscia. Formal Languages and Compilers A.Y. 2015/2016

Finite Automata. Reading: Chapter 2

6.080/6.089 GITCS Feb 12, Lecture 3

Deterministic Finite Automata

Informatique Fondamentale IMA S8

CSE 135: Introduction to Theory of Computation Decidability and Recognizability

How To Compare A Markov Algorithm To A Turing Machine

Finite Automata. Reading: Chapter 2

Push-down Automata and Context-free Grammars

FINITE STATE AND TURING MACHINES

Composability of Infinite-State Activity Automata*

Philadelphia University Faculty of Information Technology Department of Computer Science First Semester, 2007/2008.

Formal Grammars and Languages

Genetic programming with regular expressions

Lecture 2: Universality

Computer Architecture Syllabus of Qualifying Examination

Fast nondeterministic recognition of context-free languages using two queues

CS154. Turing Machines. Turing Machine. Turing Machines versus DFAs FINITE STATE CONTROL AI N P U T INFINITE TAPE. read write move.

Software Model Checking: Theory and Practice

Data Structures and Algorithms V Otávio Braga

Intrusion Detection via Static Analysis

MACM 101 Discrete Mathematics I

7.1 Our Current Model

Lecture summary for Theory of Computation

NP-Completeness and Cook s Theorem

Notes on Complexity Theory Last updated: August, Lecture 1

CGT 581 G Procedural Methods L systems

Web Data Extraction: 1 o Semestre 2007/2008

CS 301 Course Information

Modeling of Graph and Automaton in Database

Lexical Analysis and Scanning. Honors Compilers Feb 5 th 2001 Robert Dewar

Computability Theory

Automata and Formal Languages. Push Down Automata. Sipser pages Lecture 13. Tim Sheard 1

On Winning Conditions of High Borel Complexity in Pushdown Games

Computer Science Theory. From the course description:

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

If-Then-Else Problem (a motivating example for LR grammars)

Course Manual Automata & Complexity 2015

CS 341: Foundations of Computer Science II elearning Section Syllabus, Spring 2015

Lecture I FINITE AUTOMATA

Two-dimensional Languages

Automata on Infinite Words and Trees

Chapter 7 Uncomputability

Learning Analysis by Reduction from Positive Data

Introduction to Turing Machines

03 - Lexical Analysis

Computer Science 281 Binary and Hexadecimal Review

Finite Automata and Regular Languages

THEORY of COMPUTATION

Introduction. Compiler Design CSE 504. Overview. Programming problems are easier to solve in high-level languages

Regular Languages and Finite Automata

Models of Sequential Computation

Universal Turing Machine: A Model for all Computational Problems

C H A P T E R Regular Expressions regular expression

COMPUTER SCIENCE STUDENTS NEED ADEQUATE MATHEMATICAL BACKGROUND

1 Definition of a Turing machine

Theoretical Computer Science (Bridging Course) Complexity

How to make the computer understand? Lecture 15: Putting it all together. Example (Output assembly code) Example (input program) Anatomy of a Computer

DATA STRUCTURES USING C

Learning Automata and Grammars

Programming Languages CIS 443

CS5236 Advanced Automata Theory

On String Languages Generated by Spiking Neural P Systems

NFAs with Tagged Transitions, their Conversion to Deterministic Automata and Application to Regular Expressions

Compilers Lexical Analysis

FIRST and FOLLOW sets a necessary preliminary to constructing the LL(1) parsing table

Transcription:

In computer science, a pushdown automaton (PDA) is a type of automaton that employs a stack. Pushdown automata are used in theories about what can be computed by machines. They are more capable than finite-state machines but less capable than Turing machines. Deterministic pushdown automata can recognize all deterministic context-free languages while nondeterministic ones can recognize all context-free languages. Mainly the former are used in parser design. The term "pushdown" refers to the fact that the stack can be regarded as being "pushed down" like a tray dispenser at a cafeteria, since the operations never work on elements other than the top element. A stack automaton, by contrast, does allow access to and operations on deeper elements. Stack automata can recognize a strictly larger set of languages than pushdown automata. A nested stack automaton allows full access, and also allows stacked values to be entire sub-stacks rather than just single finite symbols. Here, it describes the nondeterministic pushdown automaton. Basic Structure of PDA A pushdown automaton is a way to implement a context-free grammar in a similar way we design DFA for a regular grammar. A DFA can remember a finite amount of information, but a PDA can remember an infinite amount of information. Basically a pushdown automaton is "Finite state machine" + "a stack" A pushdown automaton has three components an input tape, a control unit, and a stack with infinite size. The stack head scans the top symbol of the stack. A stack does two operations Push a new symbol is added at the top. Pop the top symbol is read and removed. A PDA may or may not read an input symbol, but it has to read the top of the stack in every transition. Page 1

A PDA can be formally described as a 7-tuple (Q,, S, δ, q 0, I, F) Q is the finite number of states is input alphabet S is stack symbols δ is the transition function Q ( {ε}) S Q S * q 0 is the initial state (q 0 Q) I is the initial stack top symbol (I S) F is a set of accepting states (F Q) The following diagram shows a transition in a PDA from a state q 1 to state q 2, labeled as a, b c This means at state q 1, if we encounter an input string a and top symbol of the stack is b, then we Page 2

pop b, push c on top of the stack and move to state q 2. Terminologies Related to PDA Instantaneous Description: The instantaneous description (ID) of a PDA is represented by a triplet (q, w, s) where q is the state w is unconsumed input s is the stack contents Turnstile Notation The "turnstile" notation is used for connecting pairs of ID's that represent one or many moves of a PDA. The process of transition is denoted by the turnstile symbol " ". Consider a PDA (Q,, S, δ, q 0, I, F). A transition can be mathematically represented by the following turnstile notation (p, aw, Tβ) (q, w, αb) This implies that while taking a transition from state p to state q, the input symbol a is consumed, and the top of the stack T is replaced by a new string α. Note If we want zero or more moves of a PDA, we have to use the symbol ( * ) for it. Final State Acceptability In final state acceptability, a PDA accepts a string when, after reading the entire string, the PDA is in a final state. From the starting state, we can make moves that end up in a final state with any stack values. The stack values are irrelevant as long as we end up in a final state. For a PDA (Q,, S, δ, q 0, I, F), the language accepted by the set of final states F is L(PDA) = {w (q 0, w, I) * (q, ε, x), q F} For any input stack string x. Empty Stack Acceptability Here a PDA accepts a string when, after reading the entire string, the PDA has emptied its stack. For a PDA (Q,, S, δ, q 0, I, F), the language accepted by the empty stack is L(PDA) = {w (q 0, w, I) * (q, ε, ε), q Q} Example Construct a PDA that accepts L= {0 n 1 n n 0} Page 3

Solution This language accepts L = {ε, 01, 0011, 000111,...} Here, in this example, the number of a and b have to be same. Initially we put a special symbol $ into the empty stack. Then at state q 2, if we encounter input 0 and top is Null, we push 0 into stack. This may iterate. And if we encounter input 1 and top is 0, we pop this 0. Then at state q 3, if we encounter input 1 and top is 0, we pop this 0. This may also iterate. And if we encounter input 1 and top is 0, we pop the top element. If the special symbol $ is encountered at top of the stack, it is popped out and it finally goes to the accepting state q 4. Example Construct a PDA that accepts L= {ww R w = (a+b) * } Solution Initially we put a special symbol $ into the empty stack. At state q 2, the w is being read. In state q 3, each 0 or 1 is popped when it matches the input. If any other input is given, the PDA will go to a dead state. When we reach that special symbol $, we go to the accepting state q 4. Page 4

Equivalence of CFL and PDA: If a grammar G is context-free, we can build an equivalent nondeterministic PDA which accepts the language that is produced by the context-free grammarg. A parser can be built for the grammar G. Also, if P is a pushdown automaton, an equivalent context-free grammar G can be constructed where L(G) = L(P) Algorithm to find PDA corresponding to a given CFG Input A CFG, G= (V, T, P, S) Output Equivalent PDA, P= (Q,, S, δ, q0, I, F) Step 1 Convert the productions of the CFG into GNF. Step 2 The PDA will have only one state {q}. Step 3 The start symbol of CFG will be the start symbol in the PDA. Step 4 All non-terminals of the CFG will be the stack symbols of the PDA and all the terminals of the CFG will be the input symbols of the PDA. Step 5 For each production in the form A ax where a is terminal and A, X are combination of terminal and non-terminals, make a transition δ (q, a, A). Page 5