Pushdown Automata

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 16

Pushadown 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

• Γ - Finite set of symbols called “Stack alphabet”


• δ - transition function
• q0 - special state called the initial state,where q0 Q
• Z0 - start/initial symbol of the pushdown store(stack)
• F - Set of Final states,subset of Q
Transition function
• denoted by δ on the tuples
• takes as an argument a triple δ(q,a,X), where
• q is a State in a Q
• a is either an Input Symbol in Σ or a=λ
• X is a Stack Symbol, that is a member of Γ
• the output is is a finite set of pairs (p,y),where
• p is a new state
• y is a string of the stack symbols that replace X at the top of the
stack
δ(q,a,X)→(p,y)
Transition function

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

• Graphical notation of PDA

• 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

• a,λ → c represent push opertion


• a,b→ λ represent Pop operation
• a,b→ c represent Replace operation
• example 2 - Construct PDA for the following language using graphical
notation
L={anbn:n≥1}
Solution
Accepted or Rejected state
• We say PDA is accepted
 The computation path is ends on accept(final) state
 All the inputs are consumed,means their is no inputs left
• We say PDA is rejected, all the paths
 either end on non-accpted state
 or it is incomplete - which is their is no a path or a possible
transition for a current input on that state and stack symbol
Exercise
• Construct a PDA for the following languages
a) L={ambncm: n,m≥0}
b) L={ambn:n≥1,m<n}
c) L={(01)n:n≥1}
Types of Push Down Automata
• Their are two types of PDA similar to Finite Automata
1. Determinstic PDA
2. Non-Deterministic PDA
1. Deterministic PDA
• center symbol is known
• Their is only one move for every situtation
δ(q0,a,Z0)→(q0,aZ0)
Cont.

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

You might also like