documentp

24
PUSH DOWN AUTOMATA (PDA)

Upload: hafeez-khan

Post on 01-Jul-2015

27 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DocumentP

PUSH DOWN AUTOMATA(PDA)

Page 2: DocumentP

DEFINATION

PDA is used to accept CFG language. PDA is an FA together

with Stack. Stack have access to unlimited amount of memory.

Page 3: DocumentP

The tape is divided into finitely many cells.

Each cell contains a symbol in an alphabet Σ.

δ which defined next state or transition.

A is the initial top symbol of stack which is

Finite.

Input TapeStack

Finite Control

δ

P

State

a l p h b te

A

Top symbol Of Stack

a

Page 4: DocumentP

PDA consisting of 7 tuples

1. Q is a finite set of state

2. Σ (Sigma) is a finite set of input alphabet

3. Γ (Gamma) is a finite set of stack alphabet

4. δ (Delta) is a transition function

5. qₒ is the start state

6. A is the initial stack symbol

7. F is the set of accepting states

Page 5: DocumentP

TRANSITION AND OPERATION IN PDA

a , b c

Meaning that if we see an “a” in the input string and the stack

contains the symbol “b” on top then we remove the “b” and add “c”.

q0 q1

a,b c

Page 6: DocumentP

• 1st Operation:

When we will on q0 state and read

“a” and “b” is the top symbol in

Stack then “b” will replace with “c”.

When “b” will be replaced with “c” then we will on state q1.

q0 q1

a,b c

a

b

h

e

&

input

top

Replace

h

e

&

c

stack

Page 7: DocumentP

• 2nd Operation:

When we will on q0 state and read

“a” and “ε (empty)” over the stack

then we will put “c” over there.

When “c” will be putted then we will on state q1.

If we want to push anything in the stack then we will used Push Operation.

Push

a

input

b

top

stack

h

e

&

q0 q1

a, ε c

b

h

e

&

c

Page 8: DocumentP

• 3rd Operation:

When we will on q0 state and read

“a” and “b” is the top symbol in

stack then we will drop “b”.

When “b” will be dropped then we will on state q1.

q0 q1

a, b ε

a

input

b

toph

e

&

Pop h

e

&

Page 9: DocumentP

• 4th Operation:

• When we will on q0 state and read

“a” and there is “ε(empty)” than

there will be no change in stack.

q0 q1

a, ε ε

a

input

b

toph

e

&

b

h

e

&

No Change

Page 10: DocumentP

a a a b b b

q0 q1 q2 q3

ε, ε &

a, ε a

b, a ε

b, a ε

ε, & ε

•When PDA Accept:

• The computation path ends in the accept state.

• All the inputs is consumed.

Σ*=aaabbb

PDA for }0:{ nba nn

Page 11: DocumentP

a a a b b b

q0 q1 q2 q3

ε, ε &

a, ε a

b, a ε

b, a ε

ε, & ε

&

Push Operation

Page 12: DocumentP

a a a b b b

q0 q1 q2 q3

ε, ε &

a, ε a

b, a ε

b, a ε

ε, & ε

&

aPush Operation

Page 13: DocumentP

a a a b b b

q0 q1 q2 q3

ε, ε &

a, ε a

b, a ε

b, a ε

ε, & ε

&

a

a

Push Operation

Page 14: DocumentP

a a a b b b

q0 q1 q2 q3

ε, ε &

a, ε a

b, a ε

b, a ε

ε, & ε

Push Operation &

a

a

a

Page 15: DocumentP

a a a b b b

q0 q1 q2 q3

ε, ε &

a, ε a

b, a ε

b, a ε

ε, & ε

&

a

a

Pop Operation

Page 16: DocumentP

a a a b b b

q0 q1 q2 q3

ε, ε &

a, ε a

b, a ε

b, a ε

ε, & ε

&

a

Pop Operation

Page 17: DocumentP

a a a b b b

q0 q1 q2 q3

ε, ε &

a, ε a

b, a ε

b, a ε

ε, & ε

&Pop Operation

Page 18: DocumentP

a a a b b b

q0 q1 q2 q3

ε, ε &

a, ε a

b, a ε

b, a ε

ε, & ε

Replace Operation

Page 19: DocumentP

q2

q2

• 2nd Example:

a b

q0 q1 q2 q3

a a a a b b b b

a , Z aZ

Z

4 4

a , a aa

b , a ε

b , a ε

ε , Z Z

q1 aaaabbb

aZ aaaaZ

q1 aaaabbbb q2 aaaabbbb

aaaZ

q3 aaaabbbb

Z

Page 20: DocumentP

•When PDA Reject:

• Either end in a non-accepting state.

• If there is no possible transition under the

current input and stack symbols.

q0 q1 q2 q3

ε, ε &

a, ε a

b, a ε

b, a ε

ε, & ε

a a b

PDA for }0:{ nba nn

Σ*=aab

Page 21: DocumentP

q0 q1 q2 q3

ε, ε &

a, ε a

b, a ε

b, a ε

ε, & ε

&

Push Operation

a a b

Page 22: DocumentP

q0 q1 q2 q3

ε, ε &

a, ε a

b, a ε

b, a ε

ε, & ε

&Push Operation

a a b

a

Page 23: DocumentP

q0 q1 q2 q3

ε, ε &

a, ε a

b, a ε

b, a ε

ε, & ε

&Push Operation

a a b

a

a

Page 24: DocumentP

q0 q1 q2 q3

ε, ε &

a, ε a

b, a ε

b, a ε

ε, & ε

&

a a b

a

Σ*=aab is rejected because there is no more possible transition. (no more input alphabet)