This document contains lecture notes on regular languages and pushdown automata (PDA) from a computer science professor. It defines regular languages as those recognized by finite state machines and context-free languages as those recognized by PDAs. It provides examples of each type of language and applications. It also includes examples of PDAs for specific languages like anbn and descriptions of the components and behavior of PDAs.
2. p.434: Regular Languages and non-
regular languages
Dr. Hussien M. Sharaf 2
Language
Defined
by
Corresponding
Accepting
Machine
Nondeter-
minism=
Determinism
Language
Closed Under
What Can Be
Decided?
Examples of
Applications
Regular
expression
Finite
automaton,
transition graph
Yes Union,productKl
eene star,
intersection,
complement
Equivalence,
emptiness,
finiteness,
membership
Text editors,
sequential
circuits,
verification
Context-
free
grammar
Pushdown
automaton
No Union,
product,
Kleene star
Emptiness,
finiteness,
membership
Parsing,
compilers
Type 0
grammar
Turing machine,
Post machine,
Pushdown
automaton
Yes Union,
product,
Kleene star
Not much Computers
3. PDA
A Pushdown Automata (PDA ) is a DFA equipped
with a single stack.
Dr. Hussien M. Sharaf 3
1
4
3
2
1 2 3 4
Input Tape
Tape cells
4. PDA
Dr. Hussien M. Sharaf 4
1. Q : A finite set of states (Q).
2. Σ : A set of input alphabet.
3. Γ (capital Gammma): A set of stack alphabet.
4. (delta): A transition function represents the set of
transitions that moves PDA to the next states.
: Q x Σ x Γ →Q.
5. q0 Q : start state.
6. F ⊆ Q is the set of final states.
ε Γ and Σ : start symbol for the stack and end symbol
for the Input Tape.
5. FA = “a 5-tuple “ (Q, Σ, , q0, F)
1. Q: {q0, q1, q2, …} is set of states.
2. Σ: {a, b, …} set of alphabet.
3. (delta): represents the set of transitions that
FA can take between its states.
: Q x Σ→Q
4. q0 Q is the start state.
5. F Q is the set of final/accepting states.
Dr. Hussien M. Sharaf
Remember and compare FA
5
6. PDA as a deterministic machine
Its inputs are
1. The current state (of its “NFA”),
2. The current input symbol (or Λ),
and
3. The current symbol on top of its
stack.
Dr. Hussien M. Sharaf 6
1
4
3
2
Its actions are:
1. Change state.
2. Change stack if needed.
8. Ex1 P.295 cohen Edition 2:
Consider the following PDA for anbn
Dr. Hussien M. Sharaf 8
9. Ex1 P.295:
Consider the following Input
Dr. Hussien M. Sharaf 9
Δ
a a
Input Tape
a b b b Δ
Start
ReadPush Δa
b
10. Ex1 P.295:
Consider the following PDA
Dr. Hussien M. Sharaf 10
a
a a
Input Tape
a b b b Δ
Start
ReadPush Δa
b
Δ
11. Ex1 P.295:
Consider the following PDA
Dr. Hussien M. Sharaf 11
a
a a
Input Tape
a b b b Δ
Start
ReadPush Δa
b
Δ
a
a
12. Ex1 P.295:
Consider the following PDA
Dr. Hussien M. Sharaf 12
a
a a
Input Tape
a b b b Δ
POP ab, Δ
a
Δ
a
Read Δ
b b
Reject
Reject
13. Ex1 P.295:
Consider the following PDA
Dr. Hussien M. Sharaf 13
a
a a
Input Tape
a b b b Δ
POP ab, Δ
a
Δ
Read Δ
b b
Reject
Reject
14. Ex1 P.295:
Consider the following PDA
Dr. Hussien M. Sharaf 14
a a
Input Tape
a b b b Δ
POP ab, Δ
a
Δ
Read Δ
b b
Reject
Reject
15. Ex1 P.295:
Consider the following PDA
Dr. Hussien M. Sharaf 15
a a
Input Tape
a b b b Δ
Read Δ Pop a,b
Accept
Δ
Reject
16. Ex2: Even Palindrome P.304
Can you list samples of words in even palindrome?
Dr. Hussien M. Sharaf 16
PUSH a READ2READ1
POP3
POP2
POP1
START
ACCEPT
PUSH b
a
b
a
a
a
b b
b
Δ
Δ
Δ
20. Assignment #5
Read Example P.308 in Cohen’s book and hand in a
stack table for input 4
* 4 + 4.
The assignment must be hand written.
Dr. Hussien M. Sharaf 20
21. PDA for Balanced strings
State diagram for
L = {0n 1n | n >= 0}
Dr. Hussien M. Sharaf 21
0,ε
0
q4
q1
(delta) is shown in
the state diagram
"ε“ or “Λ” means ignore or don’t
care for both input and stack.
$ means end for both input or
stack
q3
q2
0,0
0
1,0
pop
1,0
pop$ , $
no Action
$ , $
no Action