Docsity

From Context-Free Grammars to Pushdown Automata: Understanding the Process, Slides of Computer Science

Partial preview of the text

Download From Context-Free Grammars to Pushdown Automata: Understanding the Process and more Slides Computer Science in PDF only on Docsity!

1

Pushdown Stack Automata

2

Agenda

Pushdown Automata

 Stacks and recursiveness

 Formal Definition

18

By general principles, can carry out any

recursive computation on a stack. Can do it on a restricted version of an activation record stack, called a “ P ush d own (Stack) A utomaton” or PDA for short.

Q: What is the language generated by

S  # | aSa | bSb?

19

A: Palindromes in {a,b,#}* containing

exactly one #-symbol.

Q: Using a stack, how can we recognize

such strings?

21

PUSH

POP

read a or b?

Push it

ACCEPT

read #? (ignore stack)

read == peek? Pop Else: CRASH!

empty stack?

22

PUSH

POP

read a or b?

Push it

ACCEPT

read #? (ignore stack)

read == peek? Pop Else: CRASH!

empty stack?

Input:

aaab#baa

24

PUSH

POP

read a or b?

Push it

ACCEPT

read #? (ignore stack)

read == peek? Pop Else: CRASH!

empty stack?

a a

Input:

aaab#baa

25

PUSH

POP

read a or b?

Push it

ACCEPT

read #? (ignore stack)

read == peek? Pop Else: CRASH!

empty stack?

a a a

Input:

aaab#baa

27

PUSH

POP

read a or b?

Push it

ACCEPT

read #? (ignore stack)

read == peek? Pop Else: CRASH!

empty stack?

b a a a

Input:

aaab#baa

28

PUSH

POP

read a or b?

Push it

ACCEPT

read #? (ignore stack)

read == peek? Pop Else: CRASH!

empty stack?

a a a

Input:

aaab#baa

30

PUSH

POP

read a or b?

Push it

ACCEPT

read #? (ignore stack)

read == peek? Pop Else: CRASH!

empty stack?

a

Input:

aaab#baa REJECT (nonempty stack)

31

PUSH

POP

read a or b?

Push it

ACCEPT

read #? (ignore stack)

read == peek? Pop Else: CRASH!

empty stack?

a a

Input:

aaab#baaa

33

PUSH

POP

read a or b?

Push it

ACCEPT

read #? (ignore stack)

read == peek? Pop Else: CRASH!

empty stack?

Input:

aaab#baaa Pause input

34

PUSH

POP

read a or b?

Push it

ACCEPT

read #? (ignore stack)

read == peek? Pop Else: CRASH!

empty stack?

Input:

aaab#baaa ACCEPT