COSC 3340 Introduction to Theory of Computation University

  • Slides: 27
Download presentation
COSC 3340: Introduction to Theory of Computation University of Houston Fall 2003, Dr. Verma

COSC 3340: Introduction to Theory of Computation University of Houston Fall 2003, Dr. Verma Lecture 11 1 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

Push Down Automaton (PDA) l l Language Acceptor Model for CFLs It is an

Push Down Automaton (PDA) l l Language Acceptor Model for CFLs It is an NFA with a stack. Finite State control Input Accept/Reject Stack 2 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

PDA (contd. ) l In one move the PDA can : – – l

PDA (contd. ) l In one move the PDA can : – – l 3 change state, consume a symbol from the input tape or ignore it pop a symbol from the stack or ignore it push a symbol onto the stack or not A string is accepted provided the machine when started in the start state consumes the string and reaches a final state. Lecture 11 Uof. H - COSC 3340 - Dr. Verma

PDA (contd. ) l If PDA in state q can consume u, pop x

PDA (contd. ) l If PDA in state q can consume u, pop x from stack, change state to p, and push w on stack we show it as u, x w q 0 4 u, x ; w In JFLAP Lecture 11 q 1 Uof. H - COSC 3340 - Dr. Verma

Example of a PDA l PDA L = {anbn |n 0} Push S to

Example of a PDA l PDA L = {anbn |n 0} Push S to the stack in the beginning and then pop it at the end before accepting. 5 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 6 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 6 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 7 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 7 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 8 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 8 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 9 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 9 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 10 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 10 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 11 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 11 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 12 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 12 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 13 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 13 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 14 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 14 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 15 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 15 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 16 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 16 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 17 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 17 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 18 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 18 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 19 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 19 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 20 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 20 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 21 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 21 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 22 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 22 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 23 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 23 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 24 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

JFLAP Simulation 24 Lecture 11 Uof. H - COSC 3340 - Dr. Verma

Definition of PDA l Formally, a PDA M = (K, , s, F). where

Definition of PDA l Formally, a PDA M = (K, , s, F). where – – – 25 K -- finite set of states -- is the input alphabet -- is the tape alphabet s K -- is the start state F K -- is the set of final states (K X X ) X (K X ) Lecture 11 Uof. H - COSC 3340 - Dr. Verma

Definition of L(M) l Define * as: (1) *(q, , ) = {(q, ,

Definition of L(M) l Define * as: (1) *(q, , ) = {(q, , )} {(p, , ) |((q, , ), (p, )) } (2) *(q, uv, xy) = {(p, v, wy) | ((q, u, x), (p, w)) } l l 26 M accepts w if (f, , x) in *(s, w, ) L(M) = {w * | M accepts w} Lecture 11 Uof. H - COSC 3340 - Dr. Verma

Example l What is L(M)? Push S to the stack in the beginning and

Example l What is L(M)? Push S to the stack in the beginning and then pop it at the end before accepting. 27 Lecture 11 Uof. H - COSC 3340 - Dr. Verma