Professional Documents
Culture Documents
PUSHDOWN AUTOMATA
o Pushdown automata is a way to implement a CFG in the same way we design
DFA for a regular grammar. A DFA can remember a finite amount of
information, but a PDA can remember an infinite amount of information.
o Pushdown automata is simply an NFA augmented with an "external stack
memory". The addition of stack is used to provide a last-in-first-out memory
management capability to Pushdown automata. Pushdown automata can
store an unbounded amount of information on the stack. It can access a
limited amount of information on the stack. A PDA can push an element onto
the top of the stack and pop off an element from the top of the stack. To read
an element into the stack, the top elements must be popped off and are lost.
o A PDA is more powerful than FA. Any language which can be acceptable by FA
can also be acceptable by PDA. PDA also accepts a class of language which
even cannot be accepted by FA. Thus PDA is much more superior to FA.
PDA Components:
Input tape: The input tape is divided in many cells or symbols. The input head is
read-only and may only move from left to right, one symbol at a time.
Finite control: The finite control has some pointer which points the current symbol
which is to be read.
Stack: The stack is a structure in which we can push and remove the items from one
end only. It has an infinite size. In PDA, the stack is used to store the items
temporarily.
Γ: a stack symbol which can be pushed and popped from the stack
δ: mapping function which is used for moving from current state to next state.
Turnstile Notation:
⊢ sign describes the turnstile notation and represents one move.
(p, b, T) ⊢ (q, w, α)
In the above example, while taking a transition from state p to q, the input symbol 'b'
is consumed, and the top of the stack 'T' is represented by a new string α.
Example 1:
Design a PDA for accepting a language {a nb2n | n>=1}.
Now when we read b, we will change the state from q0 to q1 and start popping
corresponding 'a'. Hence,
1. δ(q0, b, a) = (q1, ε)
Thus this process of popping 'b' will be repeated unless all the symbols are read.
Note that popping action occurs in state q1 only.
1. δ(q1, b, a) = (q1, ε)
After reading all b's, all the corresponding a's should get popped. Hence when we
read ε as input symbol then there should be nothing in the stack. Hence the move
will be:
1. δ(q1, ε, Z) = (q2, ε)
Where
PDA = ({q0, q1, q2}, {a, b}, {a, Z}, δ, q0, Z, {q2})
Now we will simulate this PDA for the input string "aaabbbbbb".
Example 2:
Design a PDA for accepting a language {0n1m0n | m, n>=1}.
Solution: In this PDA, n number of 0's are followed by any number of 1's followed n
number of 0's. Hence the logic for design of such PDA will be as follows:
Push all 0's onto the stack on encountering first 0's. Then if we read 1, just do
nothing. Then read 0, and on each read of 0, pop one 0 from the stack.
For instance:
This scenario can be written in the ID form as:
Now we will simulate this PDA for the input string "0011100".
an input tape,
a control unit, and
a stack with infinite size.
A PDA may or may not read an input symbol, but it has to read
the top of the stack in every transition.
This means at state q1, if we encounter an input string ‘a’ and top
symbol of the stack is ‘b’, then we pop ‘b’, push ‘c’ on top of the
stack and move to state q2.
q is the state
w is unconsumed input
s is the stack contents
Turnstile Notation
A DFA can remember a finite amount of information but a PDA can remember
an infinite amount of information.
An input tape.
A control unit.
A stack with infinite size.
A PDA may or may not read input symbols, but it has to read the top of the
stack in every transaction.
A PDA can be formally described as 7-tuples
At state q1, if an input string 'a' is encountered and the top symbol of stack
is 'b' then we pop 'b', push 'c' on top of the stack and move to state q2.
Instantaneous Description (ID)
ID is an informal notation of how a PDA computes an input string and make a
decision that string is accepted or rejected.
Turnstile Notation:
⊢ sign describes the turnstile notation and represents one move.
For example,
(p, b, T) ⊢ (q, w, α)
In the above example, while taking a transition from state p to q, the input symbol 'b'
is consumed, and the top of the stack 'T' is represented by a new string α.
Example 1:
Design a PDA for accepting a language {a nb2n | n>=1}.
Now when we read b, we will change the state from q0 to q1 and start popping
corresponding 'a'. Hence,
1. δ(q0, b, a) = (q1, ε)
Thus this process of popping 'b' will be repeated unless all the symbols are read.
Note that popping action occurs in state q1 only.
1. δ(q1, b, a) = (q1, ε)
After reading all b's, all the corresponding a's should get popped. Hence when we
read ε as input symbol then there should be nothing in the stack. Hence the move
will be:
1. δ(q1, ε, Z) = (q2, ε)
Where
PDA = ({q0, q1, q2}, {a, b}, {a, Z}, δ, q0, Z, {q2})
Now we will simulate this PDA for the input string "aaabbbbbb".
Solution: In this PDA, n number of 0's are followed by any number of 1's followed n
number of 0's. Hence the logic for design of such PDA will be as follows:
Push all 0's onto the stack on encountering first 0's. Then if we read 1, just do
nothing. Then read 0, and on each read of 0, pop one 0 from the stack.
For instance:
Now we will simulate this PDA for the input string "0011100".
1. δ(q0, 0011100, Z) ⊢ δ(q0, 011100, 0Z)
2. ⊢ δ(q0, 11100, 00Z)
3. ⊢ δ(q0, 1100, 00Z)
4. ⊢ δ(q1, 100, 00Z)
5. ⊢ δ(q1, 00, 00Z)
6. ⊢ δ(q1, 0, 0Z)
7. ⊢ δ(q1, ε, Z)
8. ⊢ δ(q2, Z)
9. ACCEPT
For a PDA (Q, ∑, S, δ, q0, I, F), the language accepted by the set
of final states F is −
L(PDA) = {w | (q0, w, I) ⊢* (q, ε, x), q ∈ F}
for any input stack string x.
Empty Stack Acceptability
Here a PDA accepts a string when, after reading the entire string,
the PDA has emptied its stack.
Here, in this example, the number of ‘a’ and ‘b’ have to be same.
Initially we put a special symbol ‘$’ into the empty stack.
Then at state q2, if we encounter input 0 and top is Null, we
push 0 into stack. This may iterate. And if we encounter
input 1 and top is 0, we pop this 0.
Then at state q3, if we encounter input 1 and top is 0, we
pop this 0. This may also iterate. And if we encounter input
1 and top is 0, we pop the top element.
If the special symbol ‘$’ is encountered at top of the stack, it
is popped out and it finally goes to the accepting state q4.
Example
Construct a PDA that accepts L = { wwR | w = (a+b)* }
Solution
A push down automata is similar to deterministic finite automata except that it has a
few more properties than a DFA.The data structure used for implementing a PDA is
stack. A PDA has an output associated with every input. All the inputs are either
pushed into a stack or just ignored. User can perform the basic push and pop
operations on the stack which is use for PDA. One of the problems associated with
DFAs was that could not make a count of number of characters which were given
input to the machine. This problem is avoided by PDA as it uses a stack which
provides us this facility also.
A Pushdown Automata (PDA) can be defined as –
M = (Q, Σ, Γ, δ, q0, Ζ, F) where
Q is a finite set of states
Σ is a finite set which is called the input alphabet
Γ is a finite set which is called the stack alphabet
δ is a finite subset of Q X ( Σ ∪ {ε} X Γ X Q X Γ*) the transition relation.
q0 ∈ Q is the start state
Ζ ∈ Γ is the initial stack symbol
F ⊆ Q is the set of accepting states
Representation of State Transition –
Examples:
Input : 0 0 1 1 1 2 2 2 3 3
Result : ACCEPTED
Input : 0 0 0 1 1 2 2 2 3 3
Result : NOT ACCEPTED
Q) Construct a PDA for language L = {0 n1m | n >= 1, m >= 1, m > n+2}
Approach used in this PDA –
First 0’s are pushed into stack.When 0’s are finished, two 1’s are ignored. Thereafter
for every 1 as input a 0 is popped out of stack. When stack is empty and still some
1’s are left then all of them are ignored.
Step-1: On receiving 0 push it onto stack. On receiving 1, ignore it and
goto next state
Step-2: On receiving 1, ignore it and goto next state
Step-3: On receiving 1, pop a 0 from top of stack and go to next state
Step-4: On receiving 1, pop a 0 from top of stack. If stack is empty, on
receiving 1 ignore it and goto next state
Step-5: On receiving 1 ignore it. If input is finished then goto last state
Examples:
Input : 0 0 0 1 1 1 1 1 1
Result : ACCEPTED
Input : 0 0 0 0 1 1 1 1
Result : NOT ACCEPTED
DPDA: For every input with the current state, there is only one move.
M = (Q,?,?,q0, Z,F ,?)
?: Q*?*??Q*?*
Deterministic path
NPDA: For every input with the current state, We can have multiple moves.
M = (Q,?,?,q0, Z,F ,?)
?: Q*{???}*??2Q*?*
δ(q, ε , S) = {(q, XS), (q, ε )} δ(q, ε , X) = {(q, aXb), (q, Xb), (q, ab)} δ(q, a, a) = {(q, ε )}
δ(q, 1, 1) = {(q, ε )} Algorithm to find CFG corresponding to a given PDA Input − A CFG, G
= (V, T, P, S) Output − Equivalent PDA, P = (Q, ∑, S, δ, q0, I, F) such that the non- terminals
of the grammar G will be {Xwx | w,x ∈ Q} and the start state will be Aq0,F. Step 1 − For
every w, x, y, z ∈ Q, m ∈ S and a, b ∈ ∑, if δ (w, a, ε) contains (y, m) and (z, b, m) contains
(x, ε), add the production rule Xwx → a Xyzb in grammar G. Step 2 − For every w, x, y, z ∈
Q, add the production rule Xwx → XwyXyx in grammar G. Step 3 − For w ∈ Q, add the
production rule Xww → ε in grammar G.
TWO STACK PDA
Two stacks push down automata (PDA) includes the following factors −
A Turing machine can accept languages that are not accepted by any PDA with one stack.
The strength of pushdown automata is increased by adding extra stacks.
A PDA with two stacks has the same computation power as for a Turing Machine.
Some of the characteristics of the Turing Machine (TM) and the Two-stack
Push down automaton (Two-stack PDA) Machine are as follows −
Move the head left or Replace the symbol of each stack with a
right. string of zero or more stack symbols.
The right half of the tape is kept on one stack, and the left half on the other.
As we move along, we pop characters off one and push them onto the other.
As we can observe that FA is less powerful than any other machine. It is important
to note that DFA and NFA are of same power because every NFA can be converted
into DFA and every DFA can be converted into NFA . The Turing Machine i.e. TM
is more powerful than any other machine
(i) Finite Automata (FA) equivalence:
Finite Automata
≡ PDA with finite Stack
≡ TM with finite tape
≡ TM with unidirectional tape
≡ TM with read only tape
(ii) Pushdown Automata (PDA) equivalence:
PDA ≡ Finite Automata with Stack
(iii) Turing Machine (TM) equivalence:
Turing Machine
≡ PDA with additional Stack
≡ FA with 2 Stacks
The Applications of these Automata are given as follows:
1. Finite Automata (FA) –
For the designing of lexical analysis of a compiler.
For recognizing the pattern using regular expressions.
For the designing of the combination and sequential circuits using Mealy
and Moore Machines.
Used in text editors.
For the implementation of spell checkers.
Can be used as a model for learning and decision making.
Can parse text to extract information and structure data.
2. Push Down Automata (PDA) –
For designing the parsing phase of a compiler (Syntax Analysis).
For implementation of stack applications.
For evaluating the arithmetic expressions.
For solving the Tower of Hanoi Problem.
Can be used in software engineering, to verify and validate the correctness
of software models.
Can be used in network protocols, to parse and validate incoming
messages and to enforce specific message formats.
Can be used in cryptography, to implement secure algorithms for
encryption and decryption.
Used in string matching and pattern recognition, to search for specific
patterns in input strings.
Used in XML parsing.
Used in natural language processing applications like parsing sentences,
recognizing parts of speech, and generating syntax trees.
Used in automatic theorem proving and formal verification.
Used in formal verification of hardware and software systems.
3. Linear Bounded Automata (LBA) –
For implementation of genetic programming.
For constructing syntactic parse trees for semantic analysis of the
compiler.
For recognition of context-sensitive languages.
Used in game theory to model and analyze interactions between agents.
4. Turing Machine (TM) –
For solving any recursively enumerable problem.
For understanding complexity theory.
For implementation of neural networks.
For implementation of Robotics Applications.
For implementation of artificial intelligence.
Used as a theoretical model to analyze the time and space complexity of
algorithms.
Used in computational biology to model and analyze biological systems.
Used in artificial intelligence as a model for learning and decision making.
Used to study the relationship between classical computing and quantum
computing.
Used in digital circuit design to model and verify the behavior of digital
circuits.
Used in human-computer interaction to model and analyze the interaction
between humans and computers.