P. 1
3.3 Push-Down Automata

3.3 Push-Down Automata

|Views: 28|Likes:
Published by jyotsnagupta

More info:

Published by: jyotsnagupta on Apr 28, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PPT, PDF, TXT or read online from Scribd
See more
See less

11/03/2012

pdf

text

original

Push-down Automata

Section 3.3 Fri, Oct 21, 2005

.Push-Down Automata Recall that DFAs accept regular languages. we use a stack. These machines will need to be more powerful. To handle a language like {anbn | n u 0}. the machine needs to ³remember´ the number of as. We want to design machines similar to DFAs that will accept context-free languages. To do this. A push-down automaton (PDA) is essentially an NFA with a stack.

. is a finite alphabet of stack symbols. is the transition relation. F  K is the set of final states.. . is a finite subset of (K v ( Š {e}) v *) v (K v *). F) where       K is a finite set of states.Definition of a Push-Down Automaton A push-down automaton (PDA) is a sextuple (K. is a finite alphabet of tape symbols. .e. s  K is the start state. s. . i.

). (q. Pop the string from the stack. The first three (p. a. ). Move to state q. Move from state p.Transitions Let ((p. ))  It means that we      be a transition. Read a from the tape. Push string onto the stack. ) are ³output.´ The last two (q.´ . a. are ³input.

Transitions We will draw it as a. F. K p q .

Pushing and Popping When we push . we pop a.  as we When we push the string abc. . we push c.  When we pop the string abc. then push a. then pop b. we push the symbols of read them right to left. then pop c. we pop the symbols of as we read them from left to right (reverse order). then push b. When we pop .

if we push the string abc and then pop it. we would use three separate transitions:    Push a Push b Push c .Pushing and Popping Thus. not cba. If we wanted to reverse the order. we will get back abc.

Thus. The remaining input w. E)  (K. 7*.Configurations A configuration fully describes the current ³state´ of the PDA. . w. +*).    The current state p. The current stack contents E. a configuration is a triple (p.

w. E') in one step. denoted (p. a. transitive closure of is denoted *. E = FL. . (p'. and E' = KL for some L  +*. w. E) (p'. K))  such that w = aw'. E'). w'. w'.Computations A configuration (p. if there is a transition ((p. F). E) yields a configuration (p'. The reflexive.

e. the string w  7* is accepted if (s. e) for some f  F. The input string is accepted if   That is. and The stack is either empty or not empty.   The PDA is in either a final or a nonfinal state.Accepting Strings After processing the string on the tape. . The ending state is a final state. e) * (f. w. and The stack is empty.

The input is accepted if and only if the stack is empty once the input is processed. regardless of which state the PDA is in. regardless of whether the stack is empty. One may define acceptance ³by empty stack´ only.Accepting Strings One may define acceptance ³by final state´ only.  The input is accepted if and only if the last state is a final state.  .

e p b. a. e. a b. a.Example of a PDA Run the following PDA on the input string aaabbb. a. e. e q . a s a.

e). aa) (p. aa) (p. abbb. e) (p. bbb. bb. a) (p.Example of a PDA The steps in the processing are  (s. aabbb. b. a) (q. aaabbb. aaa) (p. e. .

What is the language of the PDA in the previous example? .The Language of a PDA The language of a PDA A is L(A) = {w  7*A accepts w}.

a. e b. e. e p . a s e. e.Example of a PDA What is the language of the following PDA? a.

Design a PDA that accepts the language {wcwR | w  7*}. Design a PDA that accepts the language {wwR | w  7*}. b}. .Examples of PDAs Let 7 = {a.

Design a PDA whose language is {ambn  0 e n < m}. .Examples of PDAs Design a PDA whose language is {ambn  0 e m < n}.

n u 0}.Examples of PDAs Design a PDA whose language is {ambncndm | m u 0. n u 0}. Design a PDA whose language is {ambmcndn | m u 0. Design a PDA whose language is {ambncpdq | m + n = p + q}. Design a PDA whose language is {ambnck | m = n or m = k}. .

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->