Chapter 5. Push-down Automata. By Dr Zalmiyah Zakaria

Similar documents
One Minute To Learn Programming: Finite Automata

Regular Sets and Expressions

Homework 3 Solutions

A Visual and Interactive Input abb Automata. Theory Course with JFLAP 4.0

flex Regular Expressions and Lexical Scanning Regular Expressions and flex Examples on Alphabet A = {a,b} (Standard) Regular Expressions on Alphabet A

FORMAL LANGUAGES, AUTOMATA AND THEORY OF COMPUTATION EXERCISES ON REGULAR LANGUAGES

Unambiguous Recognizable Two-dimensional Languages

Regular Languages and Finite Automata

Java CUP. Java CUP Specifications. User Code Additions You may define Java code to be included within the generated parser:

Generating In-Line Monitors For Rabin Automata

Bypassing Space Explosion in Regular Expression Matching for Network Intrusion Detection and Prevention Systems

Binary Representation of Numbers Autar Kaw

Solution to Problem Set 1

! What can a computer do? ! What can a computer do with limited resources? ! Don't talk about specific machines or problems.

Reasoning to Solve Equations and Inequalities

PROF. BOYAN KOSTADINOV NEW YORK CITY COLLEGE OF TECHNOLOGY, CUNY

Automata theory. An algorithmic approach. Lecture Notes. Javier Esparza

Example 27.1 Draw a Venn diagram to show the relationship between counting numbers, whole numbers, integers, and rational numbers.

FAULT TREES AND RELIABILITY BLOCK DIAGRAMS. Harry G. Kwatny. Department of Mechanical Engineering & Mechanics Drexel University

Words Symbols Diagram. abcde. a + b + c + d + e

Pointed Regular Expressions

1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall Final Exam

Modular Generic Verification of LTL Properties for Aspects

Polynomial Functions. Polynomial functions in one variable can be written in expanded form as ( )

Section 5-4 Trigonometric Functions

Regular Repair of Specifications

EQUATIONS OF LINES AND PLANES

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

CS99S Laboratory 2 Preparation Copyright W. J. Dally 2001 October 1, 2001

trademark and symbol guidelines FOR CORPORATE STATIONARY APPLICATIONS reviewed

Use Geometry Expressions to create a more complex locus of points. Find evidence for equivalence using Geometry Expressions.

Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. Date: Friday 16 th May Time: 14:00 16:00

Exponential and Logarithmic Functions

Virtual Machine. Part II: Program Control. Building a Modern Computer From First Principles.

Automated Grading of DFA Constructions

When Simulation Meets Antichains (on Checking Language Inclusion of NFAs)

Bayesian Updating with Continuous Priors Class 13, 18.05, Spring 2014 Jeremy Orloff and Jonathan Bloom

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

Section 5.2, Commands for Configuring ISDN Protocols. Section 5.3, Configuring ISDN Signaling. Section 5.4, Configuring ISDN LAPD and Call Control

Unit 6: Exponents and Radicals

Start Here. IMPORTANT: To ensure that the software is installed correctly, do not connect the USB cable until step 17. Remove tape and cardboard

Solutions for Selected Exercises from Introduction to Compiler Design

2 DIODE CLIPPING and CLAMPING CIRCUITS

Automata and Computability. Solutions to Exercises

and thus, they are similar. If k = 3 then the Jordan form of both matrices is

AntiSpyware Enterprise Module 8.5

On Recognizable Timed Languages

OPTIMA QUADRANT / OFFSET QUADRANT

Treatment Spring Late Summer Fall Mean = 1.33 Mean = 4.88 Mean = 3.

Protocol Analysis / Analysis of Software Artifacts Kevin Bierhoff

Quick Reference Guide: One-time Account Update

Integration by Substitution

On the expressive power of temporal logic

On decidability of LTL model checking for process rewrite systems

Geometry 7-1 Geometric Mean and the Pythagorean Theorem

Concept Formation Using Graph Grammars

Graphs on Logarithmic and Semilogarithmic Paper

PDF hosted at the Radboud Repository of the Radboud University Nijmegen

Chapter. Contents: A Constructing decimal numbers

Appendix D: Completing the Square and the Quadratic Formula. In Appendix A, two special cases of expanding brackets were considered:

v T R x m Version PREVIEW Practice 7 carroll (11108) 1

Lecture 5. Inner Product

DATABASDESIGN FÖR INGENJÖRER F

Outline of the Lecture. Software Testing. Unit & Integration Testing. Components. Lecture Notes 3 (of 4)

Example A rectangular box without lid is to be made from a square cardboard of sides 18 cm by cutting equal squares from each corner and then folding

Advanced Baseline and Release Management. Ed Taekema

Small Business Networking

the machine and check the components

APPLICATION NOTE Revision 3.0 MTD/PS-0534 August 13, 2008 KODAK IMAGE SENDORS COLOR CORRECTION FOR IMAGE SENSORS

Experiment 6: Friction

Mathematics. Vectors. hsn.uk.net. Higher. Contents. Vectors 128 HSN23100

e.g. f(x) = x domain x 0 (cannot find the square root of negative values)

UNLOCKING TECHNOLOGY IVECO

1.2 The Integers and Rational Numbers

1. Introduction Texts and their processing

0.1 Basic Set Theory and Interval Notation

5.2. LINE INTEGRALS 265. Let us quickly review the kind of integrals we have studied so far before we introduce a new one.

Vendor Rating for Service Desk Selection

Multiplication and Division - Left to Right. Addition and Subtraction - Left to Right.

Lecture 3 Gaussian Probability Distribution

Pure C4. Revision Notes

A.7.1 Trigonometric interpretation of dot product A.7.2 Geometric interpretation of dot product

Engineer-to-Engineer Note

Lec 2: Gates and Logic

Solenoid Operated Proportional Directional Control Valve (with Pressure Compensation, Multiple Valve Series)

Learning Workflow Petri Nets

How To Network A Smll Business

High-Performance Hardware Monitors to Protect Network Processors from Data Plane Attacks

9 CONTINUOUS DISTRIBUTIONS

Or more simply put, when adding or subtracting quantities, their uncertainties add.

Algebra Review. How well do you remember your algebra?

Small Business Networking

MODULE 3. 0, y = 0 for all y

5 a LAN 6 a gateway 7 a modem

LINEAR TRANSFORMATIONS AND THEIR REPRESENTING MATRICES

1. In the Bohr model, compare the magnitudes of the electron s kinetic and potential energies in orbit. What does this imply?

IaaS Configuration for Virtual Platforms

EasyMP Network Projection Operation Guide

Physics 43 Homework Set 9 Chapter 40 Key

Transcription:

Chpter 5 Push-down Automt By Dr Zlmiyh Zkri

Push-Down Automt Regulr expressions re string genertors they tell us how to generte ll strings in lnguge L. Finite Automt (DFA, NFA) re string cceptors they tell us if specific string w is in L. CFGs re string genertors Are there string cceptors for Context-Free lnguges? YES! Push-down utomt Sept2011 Theory of Computer Science 2

Push-Down Automt DFAs ccept regulr lnguges. Now, we wnt to design mchines similr to DFAs tht will ccept context-free lnguges. These mchines will need to e more powerful. To hndle lnguge like { n n n 0}, the mchine needs to rememer the numer of s. To do this, we use stck. A push-down utomton (PDA) is essentilly n NFA with stck.

Push-Down Automt A PDA hs some memory, ut not generl purpose, rndom-ccess memory. It uses stck, which hs two opertions Push nd Pop. Using the stck, it llows us to: Count Mtch strings Sept2011 Theory of Computer Science 4

Building PDA stte control push $ red 0 push x red 1 pop x red 1 pop x pop $ L = {0 n 1 n : n 1} Rememer ech 0 y pushing x onto the stck When we see 1, we pop n x from the stck We wnt to ccept when we hit the stck ottom $ = specil mrker for ottom

A PDA in ction stte control push $ red 0 push x red 1 pop x red 1 pop x pop $ input L = {0 n 1 n : n 1} 0 0 0 1 1 1 $ stck x x x

Nottion for PDAs push $ red 0 push x red 1 pop x red 1 pop x pop $ q 0 q 1 q 2 q 3, / $ 1, x /, $ / 0, / x 1, x / red, pop / push

Definition of PDA A pushdown utomton (PDA) is sextuple (Q,,,, q 0, F) where: Q is finite set of sttes; is the input lphet; is the stck lphet q 0 in Q is the strt stte; F Q is set of finl sttes; is the trnsition function : Q ( {}) ( {}) susets of Q ( {}) PDA ccepts w if we end up in finl stte with n empty stck

Exmple q 0 q 1 q 2 q 3, / $ 0, / x 1, x /, $ / 1, x / = {0, 1} = {$, x} (q 0,, ) = {(q 1, $)} (q 0,, $) = (q 0,, x) = (q 0, 0, ) =... : Q ( {}) ( {}) susets of Q ( {}) stte input symol pop symol stte push symol

The lnguge of PDA A PDA is nondeterministic Multiple trnsitions on sme pop/input llowed Trnsitions my ut do not hve to push or pop The lnguge of PDA is the set of ll strings in S* tht cn led the PDA to n ccepting stte

Trnsitions Let ((p,, β), (q, γ)) Δ e trnsition. It mens tht we Move from stte p. Red from the tpe, Pop the string β from the stck, Move to stte q, Push string γ onto the stck. The first three (p,, β), re input. The lst two (q, γ) re output.

Trnsitions We will drw it s or If t q 0 (p), with next input symol () nd top of stck x (), then cn consume (), pop x (), push y () onto stck nd move to q 1 (q)

Pushing nd Popping When we push β, we push the symols of β s we red them right to left. When we push the string c, we push c, then push, then push. When we pop γ, we pop the symols of γ s we red them from left to right (reverse order). When we pop the string c, we pop, then pop, then pop c.

Pushing nd Popping Thus, if we push the string c nd then pop it, we will get ck c, not c. If we wnted to reverse the order, we would use three seprte trnsitions: Push Push Push c

Configurtions A configurtion fully descries the current stte of the PDA. The current stte p. The remining input w. The current stck contents. Thus, configurtion is triple (p, w, ) (K, *, * ).

Computtions A configurtion (p, w, ) yields configurtion (p', w', ') in one step, denoted (p, w, ) (p', w', '), if there is trnsition ((p,, ), (p', )) Δ such tht w = w', =, nd ' = for some *. The reflexive, trnsitive closure of is denoted *.

Accepting Strings After processing the string on the tpe, The PDA is in either finl or nonfinl stte, nd The stck is either empty or not empty. The input string is ccepted if The ending stte is finl stte, nd The stck is empty. Tht is, the string w * is ccepted if (s, w, e) * (f, e, e) for some f F.

Accepting Strings One my define cceptnce y finl stte only. The input is ccepted if nd only if the lst stte is finl stte, regrdless of whether the stck is empty. One my define cceptnce y empty stck only. The input is ccepted if nd only if the stck is empty once the input is processed, regrdless of which stte the PDA is in.

Exmple of PDA Run the following PDA on the input string.

Exmple of PDA The steps in the processing re (s,, e) (p,, A) (p,, AA) (p,, AAA) (p,, AA) (p,, A) (q, e, e).

The Lnguge of PDA The lnguge of PDA A is L(A) = {w * A ccepts w}. Wht is the lnguge of the PDA in the previous exmple?

Exmple of PDA Wht is the lnguge of the following PDA?

Exmples of PDAs Let = {, }. Design PDA tht ccepts the lnguge {wcw R w * }. Design PDA tht ccepts the lnguge {ww R w * }.

Exmples of PDAs Design PDA whose lnguge is { m n 0 m < n}. Design PDA whose lnguge is { m n 0 n < m}.

Exmples of PDAs Design PDA whose lnguge is { m n c n d m m 0, n 0}. Design PDA whose lnguge is { m m c n d n m 0, n 0}. Design PDA whose lnguge is { m n c p d q m + n = p + q}. Design PDA whose lnguge is { m n c k m = n or m = k}.

Pushdown Automt PDAs 27

Pushdown Automton -- PDA Input String Stck Sttes 28

Initil Stck Symol Stck Stck stck hed $ z top ottom specil symol Appers t time 0 29

Input symol The Sttes Pop symol Push symol 30

, c q 1 q 2 input stck e h $ top Replce c e h $ 31

, c q 1 q 2 input stck c top Push e h $ e h $ 32

, q 1 q 2 input stck top Pop e h $ e h $ 33

, q 1 q 2 input stck e h $ top No Chnge e h $ 34

Empty Stck input, $ q 1 q 2 stck $ top Pop empty The utomton HALTS No possile trnsition fter q 2 35

A Possile Trnsition input, $ q 1 q 2 stck $ top Pop 36

Non-Determinism PDAs re non-deterministic Allowed non-deterministic trnsitions, c q 2 q 1, c q 1 q 2, c q 3 -trnsition 37

Exmple PDA PDA M, L(M) = { n n : n 0},,,,, $ $ q 0 q 1 q 2 q 3 38

Bsic Ide: L(M) = { n n : n 0} 1. Push the s on the stck 2. Mtch the s on input with s on stck,, 3. Mtch found,,, $ $ q 0 q 1 q 2 q 3 39

Execution Exmple: Input Time 0 $ Stck current stte,,,,, $ $ q q 1 q 2 q 3 0 40

Input Time 1 $ Stck,,,,, $ $ q 0 q 1 q 2 q 3 41

Input Time 2 $ Stck,,,,, $ $ q 0 q 1 q 2 q 3 42

Input Time 3 $ Stck,,,,, $ $ q 0 q 1 q 2 q 3 43

Input Time 4 $ Stck,,,,, $ $ q 0 q 1 q 2 q 3 44

Input Time 5 $ Stck,,,,, $ $ q 0 q 1 q 2 q 3 45

Input Time 6 $ Stck,,,,, $ $ q 0 q 1 q 2 q 3 46

Input Time 7 $ Stck,,,,, $ $ q 0 q 1 q 2 q 3 47

Input Time 1 $ Stck,, ccept,,, $ $ q 0 q 1 q 2 q 3 48

A string is ccepted if there is computtion such tht: All the input is consumed AND The lst stte is n ccepting stte At the end of the computtion, we do not cre out the stck contents (the stck cn e empty t the lst stte) 49

The input string is ccepted y the PDA:,,,,, $ $ q 0 q 1 q 2 q 3 50

In generl, L = { n n : n 0} is the lnguge ccepted y the PDA:,,,,, $ $ q 0 q 1 q 2 q 3 51

Rejection Exmple: Input Time 0 $ Stck current stte,, q 0,, $ $, q 1 q 2 q 3 52

Rejection Exmple: Input Time 1 $ Stck current stte,, q 0,, $ $, q 1 q 2 q 3 53

Rejection Exmple: Input Time 2 $ Stck current stte,, q 0,, $ $, q 1 q 2 q 3 54

Rejection Exmple: Input Time 3 $ Stck current stte,, q 0,, $ $, q 1 q 2 q 3 55

Rejection Exmple: Input Time 4 $ Stck current stte,, q 0,, $ $, q 1 q 2 q 3 56

Rejection Exmple: Input Time 4 reject $ Stck current stte,, q 0,, $ $, q 1 q 2 q 3 57

The input string is rejected y the PDA:,,,,, $ $ q 0 q 1 q 2 q 3 58

A string is rejected if there is no computtion such tht: All the input is consumed AND The lst stte is n ccept stte At the end of the computtion, we do not cre out the stck contents 59

Another PDA exmple L (M) = {vv R : v {,}*} PDA M,,,, q 0,, $ $ q 1 q 2 60

Bsic Ide: L (M) = {vv R : v {,}*} 1. Push v on stck 2. Guess middle 3. Mtch v R on input with v on stck of input,, 4. Mtch,, found q 0,, $ $ q 1 q 2 61

Execution Exmple: Input Time 0 $,, Stck,, q 0,, $ $ q 1 q 2 62

Input Time 1 $,, Stck,, q 0,, $ $ q 1 q 2 63

Time 2 Input $,, Stck,, q 0,, $ $ q 1 q 2 64

Time 3 Input Guess the middle of string $,, Stck,, q 0,, $ $ q 1 q 2 65

Time 4 Input $,, Stck,, q 0,, $ $ q 1 q 2 66

Input Time 5 $,, Stck,, q 0,, $ $ q q 2 1 67

Input Time 6 $,, Stck,, Accept q 0, q 1, $ $ q 2 68

Rejection Exmple: Input Time 0 $,, Stck,, q 0,, $ $ q 1 q 2 69

Input Time 1 $,, Stck,, q 0,, $ $ q 1 q 2 70

Input Time 2 $,, Stck,, q 0,, $ $ q 1 q 2 71

Input Time 3 Guess the middle of string $,, Stck,, q 0,, $ $ q 1 q 2 72

Input Time 4 $,, Stck,, q 0,, $ $ q 1 q 2 73

Input Time 5 There is no possile trnsition. Input is not consumed $,, Stck,, q 0,, $ $ q q 2 1 74

Another computtion on sme string: Input Time 0 $,, Stck,, q 0,, $ $ q 1 q 2 75

Input Time 1 $,, Stck,, q 0,, $ $ q 1 q 2 76

Input Time 2 $,, Stck,, q 0,, $ $ q 1 q 2 77

Input Time 3 $,, Stck,, q 0,, $ $ q 1 q 2 78

Input Time 4 $,, Stck,, q 0,, $ $ q 1 q 2 79

Input Time 5 No finl stte is reched $,, Stck,, q 0,, $ $ q 1 q 2 80

There is no computtion tht ccepts string L(M),,,, q 0,, $ $ q 1 q 2 81

Another PDA exmple L (M) = {w {,}*: in every prefix v, n (v) n (v)} PDA M,, q 0 82

Execution Exmple: Time 0 Input,,, $ $ Stck q 0 83

Time 1 Input,,, $ $ Stck q 0 84

Time 2 Input,,, $ $ Stck q 0 85

Time 3 Input,,, $ $ Stck Accept q 0 86

Rejection Exmple: Time 0 Input,,, $ $ Stck q 0 87

Time 1 Input,,, $ $ Stck q 0 88

Time 2 Input,,, $ $ Stck q 0 89

Time 3 Input,,, $ Stck q 0 90

Time 4 Input,,, $ Stck q 0 Hlt nd Reject 91

Pushing Strings Input symol Pop symol Push string, w q 1 q 2 92

Exmple:, cdf q 1 q 2 input stck d top f h Push h e e $ $ c pushed string 93

Another PDA exmple L (M) = {w {,}*: n (w) = n (w)} PDA M, $ 0$, 0 00,1, $ 1$, 1 11, 0, $ $ q 1 q 2 94

Execution Exmple: Input Time 0, $ 0$, 0 00,1, $ 1$, 1 11, 0 $ Stck current stte, $ $ q 1 q 2 95

Input Time 1, $ 0$, $ 1$, 0 00, 1 11,1, 0 0 $ Stck, $ $ q 1 q 2 96

Input Time 3, $ 0$, 0 00,1, $ 1$, 1 11, 0 0 $ Stck, $ $ q 1 q 2 97

Input Time 4, $ 0$, 0 00,1, $ 1$, 1 11, 0 1 $ Stck, $ $ q 1 q 2 98

Input Time 5, $ 0$, 0 00,1, $ 1$, 1 11, 0 1 1 $ Stck, $ $ q 1 q 2 99

Input Time 6, $ 0$, 0 00,1, $ 1$, 1 11, 0 1 1 $ Stck, $ $ q 1 q 2 100

Input Time 7, $ 0$, 0 00,1, $ 1$, 1 11, 0 1 $ Stck, $ $ q 1 q 2 101

Input Time 8, $ 0$, 0 00,1, $ 1$, 1 11, 0 Accept $ Stck, $ $ q 1 q 2 102

Formlities for PDAs 103

, w q 1 q 2 Trnsition function: ( 2 q1,, ) {( q, w)} 104

, w q 2 q 1, w q 3 Trnsition function: ( 3 q1,, ) {( q2, w), ( q, w)} 105

Forml Definition Pushdown Automton (PDA) M ( Q, Σ, Γ, δ, q0, z, F) Finl Sttes sttes Input lphet Stck lphet Trnsition function Initil stte Stck strt symol 106

Instntneous Description ( q, u, s) Current stte Remining input Current stck contents 107

Exmple: Time 4: Instntneous Description ( q 1,, $) Input $,, Stck,,, $ $ q 0 q 1 q 2 q 3 108