Pushdown automata I Context-free languages are more general than - - PowerPoint PPT Presentation

pushdown automata i
SMART_READER_LITE
LIVE PREVIEW

Pushdown automata I Context-free languages are more general than - - PowerPoint PPT Presentation

Pushdown automata I Context-free languages are more general than regular languages For regular languages, by definition, there are automata to recognize them What are machines to recognize CFL? Pushdown automata (PDA) Its more powerful by


slide-1
SLIDE 1

Pushdown automata I

Context-free languages are more general than regular languages For regular languages, by definition, there are automata to recognize them What are machines to recognize CFL? Pushdown automata (PDA) It’s more powerful by having a stack DFA (or NFA):

September 29, 2020 1 / 11

slide-2
SLIDE 2

Pushdown automata II

CPU 0 1 1 0 · · · input Pushdown automata: CPU 0 1 1 0 · · · input 1 1 1 0 · · · stack What is a stack? We know they are like plates in a cafeteria

September 29, 2020 2 / 11

slide-3
SLIDE 3

Pushdown automata III

An important property: last in first out Let’s see how stack can help to recognize {0n1n | n ≥ 0} If 0 is read, 0 is pushed to stack If 1 is read, 0 is popped up By checking (0, 1) pairs, we know if the input is 0n1n

September 29, 2020 3 / 11

slide-4
SLIDE 4

Example 2.14 I

Consider the following language {0n1n | n ≥ 0} q1 q2 q3 q4 ǫ, ǫ → $ 0, ǫ → 0 1, 0 → ǫ 1, 0 → ǫ ǫ, $ → ǫ

September 29, 2020 4 / 11

slide-5
SLIDE 5

Example 2.14 II

✩: a special symbol to indicate the initial state of stack How it works: q2 → q2, put 0 into stack q2 → q3 and q3 → q3, read 1 and pop 0 up The input 0011 is the same as ǫ0011ǫ

September 29, 2020 5 / 11

slide-6
SLIDE 6

Example 2.14 III

Steps: q1, ∅, ǫ q2, {$}, 0 q2, {0, $}, 0 q2, {0, 0, $}, 1 q3, {0, $}, 1 q3, {$}, ǫ q4, {} {}: contents of the stack

September 29, 2020 6 / 11

slide-7
SLIDE 7

Example 2.14 IV

We see that ✩ can be used to check if the stack is empty Consider 00011 Steps: q1, ǫ, {$} . . . q2, 0, {0, 0, 0, $} q3, 1, {0, 0, $} q3, 1, {0, $} Cannot reach q4 ⇒ rejected

September 29, 2020 7 / 11

slide-8
SLIDE 8

Formal definition of pushdown automata I

(Q, Σ, Γ, δ, q0, F) Q, Σ, Γ, F: finite sets

1

Q: states

2

Σ: alphabet

3

Γ: stack alphabet

4

δ: Q × Σǫ × Γǫ → P(Q × Γǫ)

5

q0 ∈ Q: start state

6

F ⊂ Q: set of accept states We rely on

September 29, 2020 8 / 11

slide-9
SLIDE 9

Formal definition of pushdown automata II

state, input, top of stack to decide the move q1

a,b→c

− → q2 From q1, read a, and replace top of stack b with c

September 29, 2020 9 / 11

slide-10
SLIDE 10

Formal definition of example 2.14 I

The language is {0n1n | n ≥ 0} M1 = (Q, Σ, Γ, δ, q1, F) Q = {q1, q2, q3, q4} Σ = {0, 1} Γ = {0, $} F = {q1, q4}

September 29, 2020 10 / 11

slide-11
SLIDE 11

Formal definition of example 2.14 II

1 ǫ 0 ✩ ǫ ✩ ǫ 0 ✩ ǫ q1 {(q2, $)} q2 {(q2, 0)} {(q3, ǫ)} q3 {(q3, ǫ)} {(q4, ǫ)} q4 In the definition of δ we have Σǫ × Γǫ Thus 9 columns in the table

September 29, 2020 11 / 11