Professional Documents
Culture Documents
Pushdown Automata
Pushdown Automata
Pushdown Automata
Definition
• Pushdown automata(PDA) is an enhanced Finite
Automata(FA) with stack.
a Stack - is an infinte memory which stores informtion on the
last-in first-out principle.
In stack we add the elements in a linear way.
stack has two operations
1. Push - add item to the top of stack/memory
2. Pop - remove item from the top of stack/memory
• a stack gives an extra power to recognize a non-regular
languages
Cont.
• pushdown automata can have a fixed set of states like Finite
Automata (FA)
• In PDA the states 'remember' the variables encountered in the
course of derivation of a string.
• PDA has three compoents
1. Input tape - an input alphabet
2. A finite control unit - a set of final states, and an initial state
as in the case of an FA.
3. A stack - called Pushdown store (PDS)
• with infinte size
• read-write operations
Cont.
• pushdown Automata model
Cont.
• PDA is defined in 7-tuples
P = (Q,Σ,Γ,δ,q0,Z0,F)
Where
• Q - is finite non-empty set of internal states of the control unit
• Σ - a finite non-empty input alphabet
Remark
• At any time the pda is in some state q and the PDS has some
symbols from Γ. The pda reads an input symbol a and the top
most symbol Z in PDS.
• As δ is defined on Q X ( Σ ∪ {λ}) X Γ, the PDA may make
transition without reading any input symbol (when δ(q, λ,Z) is
defined as a nonempty set for q Q and Z Γ . Such
transitions are called λ-moves.
• The PDA cannot take a transition when PDS is empty
Transition function
• example 1 - Construct PDA for the following language
L={anbn:n≥1}
Solution
δ: Q={q0,q1,q2,q3}
δ(q0,λ,Z0)→(q1,Z0) F={q3}
δ(q1,a,Z0)→(q1,aZ0) Γ={Z0,a}
δ(q1,a,a)→(q1,aa) Σ={a,b}
δ(q1,b,a)→(q2,λ) there for
δ(q2,b,a)→(q2,λ) P= (Q,Σ,Γ,δ,q0,Z0,F)
δ(q2,λ,Z0)→(q3,λ)
Graphical notation
• where
• A and B states
• a is an input alphabet and it may be λ
• b is a symbol on the top stack, this symbol is popped
• it may be λ , means the stack is niether read nor popped
• c is a symbol pushed to top of stack,
• it may be λ , means nothing is pushed
Graphical notation
2. Non-Deterministic PDA
• center symbol is unknown
• Their is only one move for every situtation
δ(q0,a,b)→(q0,ab),(q1,b),(q0,λ)
Applications of Regular Expression
• Syntax highlighting
• Data validation
• Simple parsing
• Search engines
• Search and replace dialog
– used in string searching algorithms for “find” and “find and
replace” in word processors,text editors