View
378
Download
0
Tags:
Embed Size (px)
DESCRIPTION
Theory of computation PDA
Citation preview
Theory of Computation
Lecture 7: Push Down Automata (PDA)
Cairo UniversityFCI
Dr. Hussien SharafComputer Science [email protected]
2
p.434: Regular Languages and non-regular languages
Dr. Hussien M. Sharaf
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,productKleene 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
PDAA Pushdown Automata (PDA ) is a DFA
equipped with a single stack.
Dr. Hussien M. Sharaf
1
4
3
2
1 2 3 4
Input Tape
Tape cells
4
PDA
Dr. Hussien M. Sharaf
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
6
PDA as a deterministic machine
Its inputs are1. 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
1
4
3
2
Its actions are:1. Change state.2. Change stack if needed.
7
Power of PDA
Dr. Hussien M. Sharaf
8
Ex1 P.295 cohen Edition 2:Consider the following PDA for anbn
Dr. Hussien M. Sharaf
9
Ex1 P.295:Consider the following Input
Dr. Hussien M. Sharaf
Δ
a a
Input Tape
a b b b Δ
Start
Read
Push Δa
b
10
Ex1 P.295:Consider the following PDA
Dr. Hussien M. Sharaf
aa a
Input Tape
a b b b Δ
Start
Read
Push Δa
b
Δ
11
Ex1 P.295:Consider the following PDA
Dr. Hussien M. Sharaf
a
a a
Input Tape
a b b b Δ
Start
Read
Push Δa
b
Δ
a
a
12
Ex1 P.295:Consider the following PDA
Dr. Hussien M. Sharaf
aa 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
aa 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
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
a a
Input Tape
a b b b Δ
Read
Δ Pop a,b
Accept
Δ
Reject
16
Ex2: Even Palindrome P.304Can you list samples of words in even palindrome?
Dr. Hussien M. Sharaf
PUSH a READ2READ1
POP3
POP2
POP1START
ACCEPT
PUSH b
a
b
a
a
a
b b
b
Δ
Δ
Δ
17
Ex2: Even Palindrome
Dr. Hussien M. Sharaf
Consider babbab
18
Ex2: Even Palindrome
Dr. Hussien M. Sharaf
Jump to the right part
19
Ex2: Even Palindrome
Dr. Hussien M. Sharaf
We have just read first many blanks on the TAPE
20
Assignment #5Read 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
21
PDA for Balanced strings
State diagram for
L = {0n 1n | n >= 0} Dr. Hussien M. Sharaf
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 ,00
1 ,0pop
1 ,0pop
$ , $no Action
$ , $no Action
22
Thank you
Dr. Hussien M. Sharaf