CSE 135: Introduction to Pushdown Automata

Sungjin Im

University of California, Merced

03-05-2015 I So far we considered automata with finite memory or machines with infinite memory

I Today: automata with access to an infinite stack — infinite memory but restricted access I The stack can contain an unlimited number of characters. But

I can read/erase only the top of the stack: pop I can add to only the top of the stack: push

I On longer inputs, automaton may have more items in the stack

Restricted Infinite Memory: The Stack I Today: automata with access to an infinite stack — infinite memory but restricted access I The stack can contain an unlimited number of characters. But

I can read/erase only the top of the stack: pop I can add to only the top of the stack: push

I On longer inputs, automaton may have more items in the stack

Restricted Infinite Memory: The Stack

I So far we considered automata with finite memory or machines with infinite memory I The stack can contain an unlimited number of characters. But

I can read/erase only the top of the stack: pop I can add to only the top of the stack: push

I On longer inputs, automaton may have more items in the stack

Restricted Infinite Memory: The Stack

I So far we considered automata with finite memory or machines with infinite memory

I Today: automata with access to an infinite stack — infinite memory but restricted access But

I can read/erase only the top of the stack: pop I can add to only the top of the stack: push

I On longer inputs, automaton may have more items in the stack

Restricted Infinite Memory: The Stack

I So far we considered automata with finite memory or machines with infinite memory

I Today: automata with access to an infinite stack — infinite memory but restricted access I The stack can contain an unlimited number of characters. I can add to only the top of the stack: push

I On longer inputs, automaton may have more items in the stack

Restricted Infinite Memory: The Stack

I So far we considered automata with finite memory or machines with infinite memory

I Today: automata with access to an infinite stack — infinite memory but restricted access I The stack can contain an unlimited number of characters. But

I can read/erase only the top of the stack: pop I On longer inputs, automaton may have more items in the stack

Restricted Infinite Memory: The Stack

I So far we considered automata with finite memory or machines with infinite memory

I Today: automata with access to an infinite stack — infinite memory but restricted access I The stack can contain an unlimited number of characters. But

I can read/erase only the top of the stack: pop I can add to only the top of the stack: push Restricted Infinite Memory: The Stack

I So far we considered automata with finite memory or machines with infinite memory

I Today: automata with access to an infinite stack — infinite memory but restricted access I The stack can contain an unlimited number of characters. But

I can read/erase only the top of the stack: pop I can add to only the top of the stack: push

I On longer inputs, automaton may have more items in the stack I On reading a 0, push it onto the stack I After the 0s, on reading each 1, pop a 0 I (If a 0 comes after a 1, reject) I If attempt to pop an empty stack, reject I If stack not empty at the end, reject I Else accept

Keeping Count Using the Stack

n n I An automaton can use the stack to recognize {0 1 } I After the 0s, on reading each 1, pop a 0 I (If a 0 comes after a 1, reject) I If attempt to pop an empty stack, reject I If stack not empty at the end, reject I Else accept

Keeping Count Using the Stack

n n I An automaton can use the stack to recognize {0 1 }

I On reading a 0, push it onto the stack I (If a 0 comes after a 1, reject) I If attempt to pop an empty stack, reject I If stack not empty at the end, reject I Else accept

Keeping Count Using the Stack

n n I An automaton can use the stack to recognize {0 1 }

I On reading a 0, push it onto the stack I After the 0s, on reading each 1, pop a 0 I If attempt to pop an empty stack, reject I If stack not empty at the end, reject I Else accept

Keeping Count Using the Stack

n n I An automaton can use the stack to recognize {0 1 }

I On reading a 0, push it onto the stack I After the 0s, on reading each 1, pop a 0 I (If a 0 comes after a 1, reject) I If stack not empty at the end, reject I Else accept

Keeping Count Using the Stack

n n I An automaton can use the stack to recognize {0 1 }

I On reading a 0, push it onto the stack I After the 0s, on reading each 1, pop a 0 I (If a 0 comes after a 1, reject) I If attempt to pop an empty stack, reject I Else accept

Keeping Count Using the Stack

n n I An automaton can use the stack to recognize {0 1 }

I On reading a 0, push it onto the stack I After the 0s, on reading each 1, pop a 0 I (If a 0 comes after a 1, reject) I If attempt to pop an empty stack, reject I If stack not empty at the end, reject Keeping Count Using the Stack

n n I An automaton can use the stack to recognize {0 1 }

I On reading a 0, push it onto the stack I After the 0s, on reading each 1, pop a 0 I (If a 0 comes after a 1, reject) I If attempt to pop an empty stack, reject I If stack not empty at the end, reject I Else accept I On seeing a ( push it on the stack I On seeing a ) pop a ( from the stack I If attempt to pop an empty stack, reject I If stack not empty at the end, reject I Else accept

I e.g. (())() is balanced, but ())() and (() are not

Matching Parenthesis Using the Stack

I An automaton can use the stack to recognize balanced parenthesis I On seeing a ( push it on the stack I On seeing a ) pop a ( from the stack I If attempt to pop an empty stack, reject I If stack not empty at the end, reject I Else accept

Matching Parenthesis Using the Stack

I An automaton can use the stack to recognize balanced parenthesis I e.g. (())() is balanced, but ())() and (() are not I On seeing a ) pop a ( from the stack I If attempt to pop an empty stack, reject I If stack not empty at the end, reject I Else accept

Matching Parenthesis Using the Stack

I An automaton can use the stack to recognize balanced parenthesis I e.g. (())() is balanced, but ())() and (() are not

I On seeing a ( push it on the stack I If attempt to pop an empty stack, reject I If stack not empty at the end, reject I Else accept

Matching Parenthesis Using the Stack

I An automaton can use the stack to recognize balanced parenthesis I e.g. (())() is balanced, but ())() and (() are not

I On seeing a ( push it on the stack I On seeing a ) pop a ( from the stack I If stack not empty at the end, reject I Else accept

Matching Parenthesis Using the Stack

I An automaton can use the stack to recognize balanced parenthesis I e.g. (())() is balanced, but ())() and (() are not

I On seeing a ( push it on the stack I On seeing a ) pop a ( from the stack I If attempt to pop an empty stack, reject I Else accept

Matching Parenthesis Using the Stack

I An automaton can use the stack to recognize balanced parenthesis I e.g. (())() is balanced, but ())() and (() are not

I On seeing a ( push it on the stack I On seeing a ) pop a ( from the stack I If attempt to pop an empty stack, reject I If stack not empty at the end, reject Matching Parenthesis Using the Stack

I An automaton can use the stack to recognize balanced parenthesis I e.g. (())() is balanced, but ())() and (() are not

I On seeing a ( push it on the stack I On seeing a ) pop a ( from the stack I If attempt to pop an empty stack, reject I If stack not empty at the end, reject I Else accept I Like an NFA with -transitions, but with a stack

I Stack depth unlimited: not a finite-state machine I Non-deterministic: accepts if any thread of execution accepts

Pushdown Automata (PDA)

input a b b a a b finite-state control x y x stack $

A Pushdown Automaton I Stack depth unlimited: not a finite-state machine I Non-deterministic: accepts if any thread of execution accepts

Pushdown Automata (PDA)

input a b b a a b finite-state control x y x stack $

A Pushdown Automaton

I Like an NFA with -transitions, but with a stack I Non-deterministic: accepts if any thread of execution accepts

Pushdown Automata (PDA)

input a b b a a b finite-state control x y x stack $

A Pushdown Automaton

I Like an NFA with -transitions, but with a stack

I Stack depth unlimited: not a finite-state machine Pushdown Automata (PDA)

input a b b a a b finite-state control x y x stack $

A Pushdown Automaton

I Like an NFA with -transitions, but with a stack

I Stack depth unlimited: not a finite-state machine I Non-deterministic: accepts if any thread of execution accepts I At every step:

I Consume next input symbol (or none) and pop the top symbol on stack (or none) I Based on current state, consumed input symbol and popped stack symbol, do (non-deterministically): 1. push a symbol onto stack (or push none) 2. change to a new state

a, x → y

q1 q2

If at q1, with next input symbol a and top of stack x, then can consume a, pop x, push y onto stack and move to q2 (any of a, x, y may be )

Pushdown Automata (PDA)

I Has a non-deterministic finite-state control I Consume next input symbol (or none) and pop the top symbol on stack (or none) I Based on current state, consumed input symbol and popped stack symbol, do (non-deterministically): 1. push a symbol onto stack (or push none) 2. change to a new state

a, x → y

q1 q2

If at q1, with next input symbol a and top of stack x, then can consume a, pop x, push y onto stack and move to q2 (any of a, x, y may be )

Pushdown Automata (PDA)

I Has a non-deterministic finite-state control I At every step: and pop the top symbol on stack (or none) I Based on current state, consumed input symbol and popped stack symbol, do (non-deterministically): 1. push a symbol onto stack (or push none) 2. change to a new state

a, x → y

q1 q2

If at q1, with next input symbol a and top of stack x, then can consume a, pop x, push y onto stack and move to q2 (any of a, x, y may be )

Pushdown Automata (PDA)

I Has a non-deterministic finite-state control I At every step:

I Consume next input symbol (or none) I Based on current state, consumed input symbol and popped stack symbol, do (non-deterministically): 1. push a symbol onto stack (or push none) 2. change to a new state

a, x → y

q1 q2

If at q1, with next input symbol a and top of stack x, then can consume a, pop x, push y onto stack and move to q2 (any of a, x, y may be )

Pushdown Automata (PDA)

I Has a non-deterministic finite-state control I At every step:

I Consume next input symbol (or none) and pop the top symbol on stack (or none) 1. push a symbol onto stack (or push none) 2. change to a new state

a, x → y

q1 q2

If at q1, with next input symbol a and top of stack x, then can consume a, pop x, push y onto stack and move to q2 (any of a, x, y may be )

Pushdown Automata (PDA)

I Has a non-deterministic finite-state control I At every step:

I Consume next input symbol (or none) and pop the top symbol on stack (or none) I Based on current state, consumed input symbol and popped stack symbol, do (non-deterministically): 2. change to a new state

a, x → y

q1 q2

If at q1, with next input symbol a and top of stack x, then can consume a, pop x, push y onto stack and move to q2 (any of a, x, y may be )

Pushdown Automata (PDA)

I Has a non-deterministic finite-state control I At every step:

I Consume next input symbol (or none) and pop the top symbol on stack (or none) I Based on current state, consumed input symbol and popped stack symbol, do (non-deterministically): 1. push a symbol onto stack (or push none) a, x → y

q1 q2

If at q1, with next input symbol a and top of stack x, then can consume a, pop x, push y onto stack and move to q2 (any of a, x, y may be )

Pushdown Automata (PDA)

I Has a non-deterministic finite-state control I At every step:

I Consume next input symbol (or none) and pop the top symbol on stack (or none) I Based on current state, consumed input symbol and popped stack symbol, do (non-deterministically): 1. push a symbol onto stack (or push none) 2. change to a new state (any of a, x, y may be )

Pushdown Automata (PDA)

I Has a non-deterministic finite-state control I At every step:

I Consume next input symbol (or none) and pop the top symbol on stack (or none) I Based on current state, consumed input symbol and popped stack symbol, do (non-deterministically): 1. push a symbol onto stack (or push none) 2. change to a new state

a, x → y

q1 q2

If at q1, with next input symbol a and top of stack x, then can consume a, pop x, push y onto stack and move to q2 Pushdown Automata (PDA)

I Has a non-deterministic finite-state control I At every step:

I Consume next input symbol (or none) and pop the top symbol on stack (or none) I Based on current state, consumed input symbol and popped stack symbol, do (non-deterministically): 1. push a symbol onto stack (or push none) 2. change to a new state

a, x → y

q1 q2

If at q1, with next input symbol a and top of stack x, then can consume a, pop x, push y onto stack and move to q2 (any of a, x, y may be ) Pushdown Automata (PDA): Formal Definition

A PDA P = (Q, Σ, Γ, δ, q0, F ) where I Q = Finite set of states

I Σ = Finite input alphabet

I Γ = Finite stack alphabet

I q0 = Start state I F ⊆ Q = Accepting/final states

I δ : Q × (Σ ∪ {}) × (Γ ∪ {}) → P(Q × (Γ ∪ {})) I First push a “bottom-of-the-stack” symbol $ and move to q

I On seeing a ( push it onto the stack

I On seeing a ) pop if a ( is in the stack

I Pop $ and move to final state qF

Matching Parenthesis: PDA construction

(,  → (

,  → $ , $ →  q0 q qF

), (→  I On seeing a ( push it onto the stack

I On seeing a ) pop if a ( is in the stack

I Pop $ and move to final state qF

Matching Parenthesis: PDA construction

(,  → (

,  → $ , $ →  q0 q qF

), (→ 

I First push a “bottom-of-the-stack” symbol $ and move to q I On seeing a ) pop if a ( is in the stack

I Pop $ and move to final state qF

Matching Parenthesis: PDA construction

(,  → (

,  → $ , $ →  q0 q qF

), (→ 

I First push a “bottom-of-the-stack” symbol $ and move to q

I On seeing a ( push it onto the stack I Pop $ and move to final state qF

Matching Parenthesis: PDA construction

(,  → (

,  → $ , $ →  q0 q qF

), (→ 

I First push a “bottom-of-the-stack” symbol $ and move to q

I On seeing a ( push it onto the stack

I On seeing a ) pop if a ( is in the stack Matching Parenthesis: PDA construction

(,  → (

,  → $ , $ →  q0 q qF

), (→ 

I First push a “bottom-of-the-stack” symbol $ and move to q

I On seeing a ( push it onto the stack

I On seeing a ) pop if a ( is in the stack

I Pop $ and move to final state qF ) ) ( ) ) q ( ( $ ) ( ) ) ( ) ) ) ) q q q ( $ ( $ $ ) )

q ! $ $

Matching Parenthesis: PDA execution

input ( ( ) ) ( ) ) q $ stack ) ( ) ) ( ) ) ) ) q q q ( $ ( $ $ ) )

q ! $ $

Matching Parenthesis: PDA execution

input ( ( ) ) ( ) ) ) ) ( ) ) q q $ stack ( ( $ ( ) ) ) ) q q $ ( $ ) )

q ! $ $

Matching Parenthesis: PDA execution

input ( ( ) ) ( ) ) ) ) ( ) ) q q $ stack ( ( $ ) ( ) ) q ( $ ) ) q ( $ ) )

q ! $ $

Matching Parenthesis: PDA execution

input ( ( ) ) ( ) ) ) ) ( ) ) q q $ stack ( ( $ ) ( ) ) ( ) ) q q ( $ $ ) )

q ! $ $

Matching Parenthesis: PDA execution

input ( ( ) ) ( ) ) ) ) ( ) ) q q $ stack ( ( $ ) ( ) ) ( ) ) ) ) q q q ( $ ( $ $ )

! $

Matching Parenthesis: PDA execution

input ( ( ) ) ( ) ) ) ) ( ) ) q q $ stack ( ( $ ) ( ) ) ( ) ) ) ) q q q ( $ ( $ $ ) q $ Matching Parenthesis: PDA execution

input ( ( ) ) ( ) ) ) ) ( ) ) q q $ stack ( ( $ ) ( ) ) ( ) ) ) ) q q q ( $ ( $ $ ) )

q ! $ $ I First push a “bottom-of-the-stack” symbol $ and move to a pushing state

I Push input symbols onto the stack

I Non-deterministically move to a popping state (with or without consuming a single input symbol)

I If next input symbol is same as top of stack, pop

I If $ on top of stack move to accept state

Palindrome: PDA construction

a,  → a a, a → 

,  →  ,  → $ , $ →  q0 q↓ q↑ qF a,  →  I Push input symbols onto the stack

I Non-deterministically move to a popping state (with or without consuming a single input symbol)

I If next input symbol is same as top of stack, pop

I If $ on top of stack move to accept state

Palindrome: PDA construction

a,  → a a, a → 

,  →  ,  → $ , $ →  q0 q↓ q↑ qF a,  → 

I First push a “bottom-of-the-stack” symbol $ and move to a pushing state I Non-deterministically move to a popping state (with or without consuming a single input symbol)

I If next input symbol is same as top of stack, pop

I If $ on top of stack move to accept state

Palindrome: PDA construction

a,  → a a, a → 

,  →  ,  → $ , $ →  q0 q↓ q↑ qF a,  → 

I First push a “bottom-of-the-stack” symbol $ and move to a pushing state

I Push input symbols onto the stack I If next input symbol is same as top of stack, pop

I If $ on top of stack move to accept state

Palindrome: PDA construction

a,  → a a, a → 

,  →  ,  → $ , $ →  q0 q↓ q↑ qF a,  → 

I First push a “bottom-of-the-stack” symbol $ and move to a pushing state

I Push input symbols onto the stack

I Non-deterministically move to a popping state (with or without consuming a single input symbol) I If $ on top of stack move to accept state

Palindrome: PDA construction

a,  → a a, a → 

,  →  ,  → $ , $ →  q0 q↓ q↑ qF a,  → 

I First push a “bottom-of-the-stack” symbol $ and move to a pushing state

I Push input symbols onto the stack

I Non-deterministically move to a popping state (with or without consuming a single input symbol)

I If next input symbol is same as top of stack, pop Palindrome: PDA construction

a,  → a a, a → 

,  →  ,  → $ , $ →  q0 q↓ q↑ qF a,  → 

I First push a “bottom-of-the-stack” symbol $ and move to a pushing state

I Push input symbols onto the stack

I Non-deterministically move to a popping state (with or without consuming a single input symbol)

I If next input symbol is same as top of stack, pop

I If $ on top of stack move to accept state a d a m d a m

q↓ q↓ m a $ m $ a m m

q↑ q↑ q↑ a m $ m $ $

qF

Palindrome: PDA execution m a d a m

q↓ $ d a m

q↓ a m $ a m m

q↑ q↑ q↑ a m $ m $ $

qF

Palindrome: PDA execution m a d a m a d a m

q↓ q↓ $ m $ a m m

q↑ q↑ q↑ a m $ m $ $

qF

Palindrome: PDA execution m a d a m a d a m d a m

q↓ q↓ q↓ $ m a $ m $ m

q↑ q↑ m $ $

qF

Palindrome: PDA execution m a d a m a d a m d a m

q↓ q↓ q↓ $ m a $ m $ a m

q↑ a m $ q↑ $

qF

Palindrome: PDA execution m a d a m a d a m d a m

q↓ q↓ q↓ $ m a $ m $ a m m

q↑ q↑ a m m $ $ qF

Palindrome: PDA execution m a d a m a d a m d a m

q↓ q↓ q↓ $ m a $ m $ a m m

q↑ q↑ q↑ a m $ m $ $ Palindrome: PDA execution m a d a m a d a m d a m

q↓ q↓ q↓ $ m a $ m $ a m m

q↑ q↑ q↑ a m $ m $ $

qF I In the case of an NFA (or DFA), it is the state contents

I In the case of a PDA, it is the state + stack contents

Definition An instantaneous description of a PDA P = (Q, Σ, Γ, δ, q0, F ) is a pair hq, σi, where q ∈ Q and σ ∈ Γ∗

Instantaneous Description

In order to describe a machine’s execution, we need to capture a “snapshot” of the machine that completely determines future behavior I In the case of a PDA, it is the state + stack contents

Definition An instantaneous description of a PDA P = (Q, Σ, Γ, δ, q0, F ) is a pair hq, σi, where q ∈ Q and σ ∈ Γ∗

Instantaneous Description

In order to describe a machine’s execution, we need to capture a “snapshot” of the machine that completely determines future behavior

I In the case of an NFA (or DFA), it is the state contents Definition An instantaneous description of a PDA P = (Q, Σ, Γ, δ, q0, F ) is a pair hq, σi, where q ∈ Q and σ ∈ Γ∗

Instantaneous Description

In order to describe a machine’s execution, we need to capture a “snapshot” of the machine that completely determines future behavior

I In the case of an NFA (or DFA), it is the state contents

I In the case of a PDA, it is the state + stack contents Instantaneous Description

In order to describe a machine’s execution, we need to capture a “snapshot” of the machine that completely determines future behavior

I In the case of an NFA (or DFA), it is the state contents

I In the case of a PDA, it is the state + stack contents

Definition An instantaneous description of a PDA P = (Q, Σ, Γ, δ, q0, F ) is a pair hq, σi, where q ∈ Q and σ ∈ Γ∗ I r0 = q1, and s0 = σ1,

I rk = q2, and sk = σ2,

I for every i,(ri+1, b) ∈ δ(ri , xi+1, a) such that si = as and ∗ si+1 = bs, where a, b ∈ Γ ∪ {} and s ∈ Γ

Computation

Definition ∗ For a PDA P = (Q, Σ, Γ, δ, q0, F ), string w ∈ Σ , and instantaneous descriptions hq1, σ1i and hq2, σ2i, we say w hq1, σ1i −→P hq2, σ2i iff there is a sequence of instanteous descriptions hr0, s0i, hr1, s1i,... hrk , sk i and a sequence x1, x2,... xk , where for each i, xi ∈ Σ ∪ {}, such that

I w = x1x2 ··· xk , I rk = q2, and sk = σ2,

I for every i,(ri+1, b) ∈ δ(ri , xi+1, a) such that si = as and ∗ si+1 = bs, where a, b ∈ Γ ∪ {} and s ∈ Γ

Computation

Definition ∗ For a PDA P = (Q, Σ, Γ, δ, q0, F ), string w ∈ Σ , and instantaneous descriptions hq1, σ1i and hq2, σ2i, we say w hq1, σ1i −→P hq2, σ2i iff there is a sequence of instanteous descriptions hr0, s0i, hr1, s1i,... hrk , sk i and a sequence x1, x2,... xk , where for each i, xi ∈ Σ ∪ {}, such that

I w = x1x2 ··· xk ,

I r0 = q1, and s0 = σ1, I for every i,(ri+1, b) ∈ δ(ri , xi+1, a) such that si = as and ∗ si+1 = bs, where a, b ∈ Γ ∪ {} and s ∈ Γ

Computation

Definition ∗ For a PDA P = (Q, Σ, Γ, δ, q0, F ), string w ∈ Σ , and instantaneous descriptions hq1, σ1i and hq2, σ2i, we say w hq1, σ1i −→P hq2, σ2i iff there is a sequence of instanteous descriptions hr0, s0i, hr1, s1i,... hrk , sk i and a sequence x1, x2,... xk , where for each i, xi ∈ Σ ∪ {}, such that

I w = x1x2 ··· xk ,

I r0 = q1, and s0 = σ1,

I rk = q2, and sk = σ2, Computation

Definition ∗ For a PDA P = (Q, Σ, Γ, δ, q0, F ), string w ∈ Σ , and instantaneous descriptions hq1, σ1i and hq2, σ2i, we say w hq1, σ1i −→P hq2, σ2i iff there is a sequence of instanteous descriptions hr0, s0i, hr1, s1i,... hrk , sk i and a sequence x1, x2,... xk , where for each i, xi ∈ Σ ∪ {}, such that

I w = x1x2 ··· xk ,

I r0 = q1, and s0 = σ1,

I rk = q2, and sk = σ2,

I for every i,(ri+1, b) ∈ δ(ri , xi+1, a) such that si = as and ∗ si+1 = bs, where a, b ∈ Γ ∪ {} and s ∈ Γ x1= x2=( x3=( x4=) x5=( hq0, i −→ hq, $i −→ hq, ($i −→ hq, (($i −→ hq, ($i −→ hq, (($i

Example of Computation

Example

(,  → (

,  → $ , $ →  q0 q qF

), (→ 

(()( hq0, i −→ hq, (($i because Example of Computation

Example

(,  → (

,  → $ , $ →  q0 q qF

), (→ 

(()( hq0, i −→ hq, (($i because

x1= x2=( x3=( x4=) x5=( hq0, i −→ hq, $i −→ hq, ($i −→ hq, (($i −→ hq, ($i −→ hq, (($i for some ∗ w q ∈ F and σ ∈ Γ , hq0, i −→P hq, σi Definition The language recognized/accepted by a PDA ∗ P = (Q, Σ, Γ, δ, q0, F ) is L(P) = {w ∈ Σ | P accepts w}. A language L is said to be accepted/recognized by P if L = L(P).

Acceptance/Recognition

Definition ∗ A PDA P = (Q, Σ, Γ, δ, q0, F ) accepts a string w ∈ Σ iff Definition The language recognized/accepted by a PDA ∗ P = (Q, Σ, Γ, δ, q0, F ) is L(P) = {w ∈ Σ | P accepts w}. A language L is said to be accepted/recognized by P if L = L(P).

Acceptance/Recognition

Definition ∗ A PDA P = (Q, Σ, Γ, δ, q0, F ) accepts a string w ∈ Σ iff for some ∗ w q ∈ F and σ ∈ Γ , hq0, i −→P hq, σi A language L is said to be accepted/recognized by P if L = L(P).

Acceptance/Recognition

Definition ∗ A PDA P = (Q, Σ, Γ, δ, q0, F ) accepts a string w ∈ Σ iff for some ∗ w q ∈ F and σ ∈ Γ , hq0, i −→P hq, σi Definition The language recognized/accepted by a PDA ∗ P = (Q, Σ, Γ, δ, q0, F ) is L(P) = {w ∈ Σ | P accepts w}. Acceptance/Recognition

Definition ∗ A PDA P = (Q, Σ, Γ, δ, q0, F ) accepts a string w ∈ Σ iff for some ∗ w q ∈ F and σ ∈ Γ , hq0, i −→P hq, σi Definition The language recognized/accepted by a PDA ∗ P = (Q, Σ, Γ, δ, q0, F ) is L(P) = {w ∈ Σ | P accepts w}. A language L is said to be accepted/recognized by P if L = L(P). Theorem For every CFG G, there is a PDA P such that L(G) = L(P). In addition, for every PDA P, there is a CFG G such that L(P) = L(G). Thus, L is context-free iff there is a PDA P such that L = L(P). Proof. Skipped. 

Expressive Power of CFGs and PDAs

CFGs and PDAs have equivalent expressive powers. More formally, ... Thus, L is context-free iff there is a PDA P such that L = L(P). Proof. Skipped. 

Expressive Power of CFGs and PDAs

CFGs and PDAs have equivalent expressive powers. More formally, ... Theorem For every CFG G, there is a PDA P such that L(G) = L(P). In addition, for every PDA P, there is a CFG G such that L(P) = L(G). Proof. Skipped. 

Expressive Power of CFGs and PDAs

CFGs and PDAs have equivalent expressive powers. More formally, ... Theorem For every CFG G, there is a PDA P such that L(G) = L(P). In addition, for every PDA P, there is a CFG G such that L(P) = L(G). Thus, L is context-free iff there is a PDA P such that L = L(P). Expressive Power of CFGs and PDAs

CFGs and PDAs have equivalent expressive powers. More formally, ... Theorem For every CFG G, there is a PDA P such that L(G) = L(P). In addition, for every PDA P, there is a CFG G such that L(P) = L(G). Thus, L is context-free iff there is a PDA P such that L = L(P). Proof. Skipped.