Pushdown Automata PDAs

1 / 90

# Pushdown Automata PDAs - PowerPoint PPT Presentation

Pushdown Automata PDAs Pushdown Automaton -- PDA Input String Stack States Initial Stack Symbol Stack Stack stack head top bottom special symbol Appears at time 0 The States Pop symbol Input symbol Push symbol input stack top Replace input stack top Push input stack

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about 'Pushdown Automata PDAs' - Sophia

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### Pushdown AutomataPDAs

Costas Busch - RPI

Pushdown Automaton -- PDA

Input String

Stack

States

Costas Busch - RPI

Initial Stack Symbol

Stack

Stack

stack

top

bottom

special symbol

Appears at time 0

Costas Busch - RPI

The States

Pop

symbol

Input

symbol

Push

symbol

Costas Busch - RPI

input

stack

top

Replace

Costas Busch - RPI

input

stack

top

Push

Costas Busch - RPI

input

stack

top

Pop

Costas Busch - RPI

input

stack

top

No Change

Costas Busch - RPI

Empty Stack

input

stack

empty

Pop

top

When the stack gets empty,

the automaton HALTS

(no more transitions after )

Costas Busch - RPI

A Possible Transition

input

stack

Pop

top

Costas Busch - RPI

Non-Determinism

PDAs are non-deterministic

Allowed non-deterministic transitions

Costas Busch - RPI

Example PDA

PDA :

Costas Busch - RPI

Basic Idea:

• Push the a’s
• on the stack

2. Match the b’s on input

with a’s on stack

3. Match

found

Costas Busch - RPI

Execution Example:

Time 0

Input

Stack

current

state

Costas Busch - RPI

Time 1

Input

Stack

Costas Busch - RPI

Time 2

Input

Stack

Costas Busch - RPI

Time 3

Input

Stack

Costas Busch - RPI

Time 4

Input

Stack

Costas Busch - RPI

Time 5

Input

Stack

Costas Busch - RPI

Time 6

Input

Stack

Costas Busch - RPI

Time 7

Input

Stack

Costas Busch - RPI

Time 8

Input

Stack

accept

Costas Busch - RPI

A string is accepted if there is

a computation such that:

All the input is consumed

AND

The last state is an accepting state

At the end of the computation,

we do not care about the stack contents

(the stack can be empty at the last state)

Costas Busch - RPI

The input string

is accepted by the PDA:

Costas Busch - RPI

In general,

is the language accepted by the PDA:

Costas Busch - RPI

Rejection Example:

Time 0

Input

Stack

current

state

Costas Busch - RPI

Rejection Example:

Time 1

Input

Stack

current

state

Costas Busch - RPI

Rejection Example:

Time 2

Input

Stack

current

state

Costas Busch - RPI

Rejection Example:

Time 3

Input

Stack

current

state

Costas Busch - RPI

Rejection Example:

Time 4

Input

Stack

current

state

Costas Busch - RPI

Rejection Example:

Time 4

Input

Stack

reject

current

state

Costas Busch - RPI

The input string

is rejected by the PDA:

Costas Busch - RPI

A string is rejected if there is

no computation such that:

All the input is consumed

AND

The last state is an accept state

At the end of the computation,

we do not care about the stack contents

Costas Busch - RPI

Another PDA example

PDA :

Costas Busch - RPI

Basic Idea:

• Push v
• on stack

3. Match on input

with v on stack

2. Guess

middle

of input

4. Match

found

Costas Busch - RPI

Execution Example:

Time 0

Input

Stack

Costas Busch - RPI

Time 1

Input

Stack

Costas Busch - RPI

Time 2

Input

Stack

Costas Busch - RPI

Time 3

Input

Guess the middle

of string

Stack

Costas Busch - RPI

Time 4

Input

Stack

Costas Busch - RPI

Time 5

Input

Stack

Costas Busch - RPI

Time 6

Input

Stack

accept

Costas Busch - RPI

Rejection Example:

Time 0

Input

Stack

Costas Busch - RPI

Time 1

Input

Stack

Costas Busch - RPI

Time 2

Input

Stack

Costas Busch - RPI

Time 3

Input

Guess the middle

of string

Stack

Costas Busch - RPI

Time 4

Input

Stack

Costas Busch - RPI

Time 5

There is no possible transition.

Input

Input is not consumed

Stack

Costas Busch - RPI

Another computation on same string:

Input

Time 0

Stack

Costas Busch - RPI

Time 1

Input

Stack

Costas Busch - RPI

Time 2

Input

Stack

Costas Busch - RPI

Time 3

Input

Stack

Costas Busch - RPI

Time 4

Input

Stack

Costas Busch - RPI

Time 5

Input

No final state

is reached

Stack

Costas Busch - RPI

There is no computation

that accepts string

Costas Busch - RPI

Another PDA example

PDA

Costas Busch - RPI

Execution Example:

Time 0

Input

Stack

Costas Busch - RPI

Time 1

Input

Stack

Costas Busch - RPI

Time 2

Input

Stack

Costas Busch - RPI

Time 3

Input

Stack

accept

Costas Busch - RPI

Rejection example:

Time 0

Input

Stack

Costas Busch - RPI

Time 1

Input

Stack

Costas Busch - RPI

Time 2

Input

Stack

Costas Busch - RPI

Time 3

Input

Stack

Costas Busch - RPI

Time 4

Input

Stack

Halt and Reject

Costas Busch - RPI

Pushing Strings

Pop

symbol

Input

symbol

Push

string

Costas Busch - RPI

Example:

input

pushed

string

stack

top

Push

Costas Busch - RPI

Another PDA example

PDA

Costas Busch - RPI

Execution Example:

Time 0

Input

Stack

current

state

Costas Busch - RPI

Time 1

Input

Stack

Costas Busch - RPI

Time 3

Input

Stack

Costas Busch - RPI

Time 4

Input

Stack

Costas Busch - RPI

Time 5

Input

Stack

Costas Busch - RPI

Time 6

Input

Stack

Costas Busch - RPI

Time 7

Input

Stack

Costas Busch - RPI

Time 8

Input

Stack

accept

Costas Busch - RPI

### Formalities for PDAs

Costas Busch - RPI

Transition function:

Costas Busch - RPI

Transition function:

Costas Busch - RPI

Formal Definition

Pushdown Automaton (PDA)

Accept

states

States

Input

alphabet

Stack

start

symbol

Transition

function

Initial

state

Stack

alphabet

Costas Busch - RPI

Instantaneous Description

Current

state

Current

stack

contents

Remaining

input

Costas Busch - RPI

Example:

Instantaneous Description

Input

Time 4:

Stack

Costas Busch - RPI

Example:

Instantaneous Description

Input

Time 5:

Stack

Costas Busch - RPI

We write:

Time 4

Time 5

Costas Busch - RPI

A computation:

Costas Busch - RPI

For convenience we write:

Costas Busch - RPI

Formal Definition

Language accepted by PDA :

Initial state

Accept state

Costas Busch - RPI

Example:

PDA :

Costas Busch - RPI

PDA :

Costas Busch - RPI

Therefore:

PDA :

Costas Busch - RPI