documentp

Post on 01-Jul-2015

27 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

PUSH DOWN AUTOMATA(PDA)

DEFINATION

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

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

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

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

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

• 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

• 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

• 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

&

• 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

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

a a a b b b

q0 q1 q2 q3

ε, ε &

a, ε a

b, a ε

b, a ε

ε, & ε

&

Push Operation

a a a b b b

q0 q1 q2 q3

ε, ε &

a, ε a

b, a ε

b, a ε

ε, & ε

&

aPush Operation

a a a b b b

q0 q1 q2 q3

ε, ε &

a, ε a

b, a ε

b, a ε

ε, & ε

&

a

a

Push Operation

a a a b b b

q0 q1 q2 q3

ε, ε &

a, ε a

b, a ε

b, a ε

ε, & ε

Push Operation &

a

a

a

a a a b b b

q0 q1 q2 q3

ε, ε &

a, ε a

b, a ε

b, a ε

ε, & ε

&

a

a

Pop Operation

a a a b b b

q0 q1 q2 q3

ε, ε &

a, ε a

b, a ε

b, a ε

ε, & ε

&

a

Pop Operation

a a a b b b

q0 q1 q2 q3

ε, ε &

a, ε a

b, a ε

b, a ε

ε, & ε

&Pop Operation

a a a b b b

q0 q1 q2 q3

ε, ε &

a, ε a

b, a ε

b, a ε

ε, & ε

Replace Operation

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

•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

q0 q1 q2 q3

ε, ε &

a, ε a

b, a ε

b, a ε

ε, & ε

&

Push Operation

a a b

q0 q1 q2 q3

ε, ε &

a, ε a

b, a ε

b, a ε

ε, & ε

&Push Operation

a a b

a

q0 q1 q2 q3

ε, ε &

a, ε a

b, a ε

b, a ε

ε, & ε

&Push Operation

a a b

a

a

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)

top related