The Wayback Machine - https://web.archive.org/web/20241116141407/https://www.geeksforgeeks.org/introduction-of-pushdown-automata/
Open In App

Introduction of Pushdown Automata

Last Updated : 16 Oct, 2024
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

We have already discussed finite automata. But finite automata can be used to accept only regular languages. Pushdown Automata is a finite automata with extra memory called stack which helps Pushdown automata to recognize Context Free Languages. This article describes pushdown automata in detail.

Pushdown Automata

A Pushdown Automata (PDA) can be defined as : 

  • Q is the set of states
  • ∑is the set of input symbols
  • Γ is the set of pushdown symbols (which can be pushed and popped from the stack)
  • q0 is the initial state
  • Z is the initial pushdown symbol (which is initially present in the stack)
  • F is the set of final states
  • δ is a transition function that maps Q x {Σ ∪ ∈} x Γ into Q x Γ*. In a given state, the PDA will read the input symbol and stack symbol (top of the stack) move to a new state, and change the symbol of the stack.

Instantaneous Description (ID) 

Instantaneous Description (ID) is an informal notation of how a PDA “computes” an input string and makes a decision whether that string is accepted or rejected. 

An ID is a triple (q, w, α), where: 
1. q is the current state. 
2. w is the remaining input. 
3.α is the stack contents, top at the left. 

Turnstile Notation 

⊢ sign is called a “turnstile notation” and represents 
one move. 
⊢* sign represents a sequence of moves. 
Eg- (p, b, T) ⊢ (q, w, α) 
This implies that while taking a transition from state p to state q, the input symbol ‘b’ is consumed, and the top of the stack ‘T’ is replaced by a new string ‘α’ 

Example : Define the pushdown automata for language {anbn | n > 0} 
Solution : M = where Q = { q0, q1 } and Σ = { a, b } and Γ = { A, Z } and δ is given by : 

δ( q0, a, Z ) = { ( q0, AZ ) } 
δ( q0, a, A) = { ( q0, AA ) } 
δ( q0, b, A) = { ( q1, ∈) } 
δ( q1, b, A) = { ( q1, ∈) } 
δ( q1, ∈, Z) = { ( q1, ∈) } 
  
Let us see how this automata works for aaabbb. 
 

PDA Transition Table

Explanation : Initially, the state of automata is q0 and symbol on stack is Z and the input is aaabbb as shown in row 1. On reading ‘a’ (shown in bold in row 2), the state will remain q0 and it will push symbol A on stack. On next ‘a’ (shown in row 3), it will push another symbol A on stack. After reading 3 a’s, the stack will be AAAZ with A on the top. After reading ‘b’ (as shown in row 5), it will pop A and move to state q1 and stack will be AAZ. When all b’s are read, the state will be q1 and stack will be Z. In row 8, on input symbol ‘∈’ and Z on stack, it will pop Z and stack will be empty. This type of acceptance is known as acceptance by empty stack. 

Push Down Automata State Diagram:

PDA Example

State Diagram for above Push Down Automata

  
Note :  

  • The above pushdown automaton is deterministic in nature because there is only one move from a state on an input symbol and stack symbol.
  • The non-deterministic pushdown automata can have more than one move from a state on an input symbol and stack symbol.
  • It is not always possible to convert non-deterministic pushdown automata to deterministic pushdown automata.
  • The expressive power of non-deterministic PDA is more as compared to expressive deterministic PDA as some languages are accepted by NPDA but not by deterministic PDA which will be discussed in the next article.
  • The pushdown automata can either be implemented using acceptance by empty stack or acceptance by final state and one can be converted to another.

  
Question: Which of the following pairs have DIFFERENT expressive power? 

A. Deterministic finite automata(DFA) and Non-deterministic finite automata(NFA) 
B. Deterministic push down automata(DPDA)and Non-deterministic push down automata(NPDA) 
C. Deterministic single-tape Turing machine and Non-deterministic single-tape Turing machine 
D. Single-tape Turing machine and the multi-tape Turing machine 

Solution : Every NFA can be converted into DFA. So, there expressive power is same. As discussed above, every NPDA can’t be converted to DPDA. So, the power of NPDA and DPDA is not the same. Hence option (B) is correct. 

Conclusion

In conclusion, Pushdown Automata (PDA) are an important concept in computer science and formal language theory. They extend the capabilities of finite automata by using a stack, which allows them to handle a broader range of languages, particularly context-free languages. PDAs can recognize patterns and structures that simpler models cannot, making them essential for parsing and processing languages in compilers and other applications. Understanding PDAs helps in grasping how more complex systems operate and enhances our knowledge of computation and algorithms.

Frequently Asked Questions on Introduction of Pushdown Automata – FAQs

How does a PDA work?

A PDA reads an input string one symbol at a time. It can push symbols onto a stack or pop symbols off the stack based on the rules defined for the automaton.

What is the purpose of the stack in a PDA?

The stack allows the PDA to remember information from previous input symbols. This makes it capable of handling more complex languages than finite automata, which don’t have a stack.

What types of languages can a PDA recognize?

PDAs can recognize context-free languages, which include many programming languages and nested structures, like parentheses in expressions.


Previous Article
Next Article

Similar Reads

Difference Between Pushdown Automata and Finite Automata
Two important computational models in automata theory that are used to identify various language kinds are Pushdown Automata (PDA) and Finite Automata (FA). Both automata process strings as input and switch between states according to pre-established rules. Still, their memory capacities account for the majority of the variance. Pushdown Automata h
5 min read
Construct Pushdown Automata for given languages
Prerequisite - Pushdown Automata, Pushdown Automata Acceptance by Final State 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
4 min read
Pushdown Automata Acceptance by Final State
We have discussed Pushdown Automata (PDA) and its acceptance by empty stack article. Now, in this article, we will discuss how PDA can accept a CFL based on the final state. Given a PDA P as: P = (Q, Σ, Γ, δ, q0, Z, F) The language accepted by P is the set of all strings consuming which PDA can move from initial state to final state irrespective of
4 min read
Construct Pushdown Automata for all length palindrome
A Pushdown Automaton (PDA) is like an epsilon Non deterministic Finite Automata (NFA) with infinite stack. PDA is a way to implement context free languages. Hence, it is important to learn, how to draw PDA. Here, take the example of odd length palindrome: Que-1: Construct a PDA for language L = {wcw' | w={0, 1}*} where w' is the reverse of w. Appro
6 min read
Construct Pushdown automata for L = {0n1m2m3n | m,n ≥ 0}
Prerequisite - Pushdown automata, Pushdown automata acceptance by final state Pushdown automata (PDA) plays a significant role in compiler design. Therefore there is a need to have a good hands on PDA. Our aim is to construct a PDA for L = {0n1m2m3n | m,n ≥ 0} Examples - Input : 00011112222333 Output : Accepted Input : 0001122233 Output : Not Accep
3 min read
Construct Pushdown automata for L = {a(2*m)c(4*n)dnbm | m,n ≥ 0}
Prerequisite – Pushdown automata, Pushdown automata acceptance by final state PDA plays a very important role in task of compiler designing. That is why there is a need to have a good practice on PDA. Our objective is to construct a PDA for L = {a(2*m)c(4*n)dnbm | m,n ≥ 0} Examples - Input: aaccccdb Output: Accepted Input: aaaaccccccccddbb Output:
3 min read
Construct Pushdown automata for L = {0n1m2(n+m) | m,n ≥ 0}
Prerequisite - Pushdown automata, NPDA for accepting the language L = {ambnc(m+n) | m,n ≥ 1} PDA plays a very important role in task of compiler designing. That is why there is a need to have a good practice on PDA. Our objective is to construct a PDA which accepts a string of the form {(0^n)(1^m)(2^(n+m))} Example- Input: 00001112222222 Output: Ac
2 min read
Detailed Study of PushDown Automata
According to the Chomsky Hierarchy, the requirement of a certain type of grammar to generate a language is often clubbed with a suitable machine that can be used to accept the same language. When the grammar is simple, the language becomes more complex, hence we require a more powerful machine to understand the language and accept it. Example: Type
3 min read
Construct Pushdown automata for L = {0m1(n+m)2n | m,n ≥ 0}
Prerequisite – Pushdown automata, NPDA for accepting the language L = {amb(n+m)cm | m, n >= 1} Problem: Construct Pushdown automata for L = {0m1(n+m)2n | m,n ≥ 0} Example: Input: 011122 Output: Accepted Input: 00000112222 Output: Not Accepted Approach used in this PDA – There can be four cases while processing the given input string. Case 1-
2 min read
Construct Pushdown automata for L = {0(n+m)1m2n | m, n ≥ 0}
Prerequisite – Pushdown automata Problem: Construct Pushdown automata for L = {0(n+m)1m2n | m, n ≥ 0} Similar PDA's- This PDA seems to be similar to PDA of S2 = {0m1(n+m)2n} but the production is different. S2 will produce output which have no of 1's equal to the sum of no of 0's and 2's, while S1 does not. This PDA seems to be similar to PDA of
3 min read
Construct Pushdown automata for L = {a^n b a^2n | n ≥ 0}
Prerequisites: Introduction of Pushdown AutomataConstruct Pushdown Automata for given languagesProblem- Construct PDA for the language L = {anba2n | n ≥ 0}. This means the PDA should have twice as many as a's after b than before b, and there should be one and only one b. Examples: INPUT : aaabaaaaaaOUTPUT : AcceptedINPUT : aaaaabaaaaOUTPUT : Reject
1 min read
Introduction to Linear Bounded Automata (LBA)
History :In 1960, associate degree automaton model was introduced by Myhill and these days this automation model is understood as deterministic linear bounded automaton. After this, another scientist named Landweber worked on this and proposed that the languages accepted by a deterministic LBA are continually context-sensitive languages. In 1964, K
2 min read
Introduction of Finite Automata
Finite automata are abstract machines used to recognize patterns in input sequences, forming the basis for understanding regular languages in computer science. They consist of states, transitions, and input symbols, processing each symbol step-by-step. If the machine ends in an accepting state after processing the input, it is accepted; otherwise,
4 min read
Introduction to Queue Automata
Queue Automata (QA) is an extended computational model of Finite Automata which is capable of performing several tasks more complex than those of Finite Automata due to its incorporation of a queue data type. This queue helps a Queue Automata (QA) to remember more about the inputs hence making it easy for more complex pattern recognition and proces
4 min read
Generating regular expression from Finite Automata
Prerequisite - Introduction of FA, Regular expressions, grammar and language, Designing FA from Regular Expression There are two methods to convert FA to the regular expression: 1. State Elimination Method:Step 1 - If the start state is an accepting state or has transitions in, add a new non-accepting start state and add an €-transition between the
3 min read
Theory of Computation | Regular languages and finite automata | Question 2
What is the complement of the language accepted by the NFA shown below? (A) A (B) B (C) C (D) D Answer: (B) Explanation: Quiz of this QuestionPlease comment below if you find anything wrong in the above post
1 min read
Practice problems on finite automata
Que-1: Draw a deterministic and non-deterministic finite automate which accept 00 and 11 at the end of a string containing 0, 1 in it, e.g., 01010100 but not 000111010. Explanation - Design a DFA and NFA of a same string if input value reaches the final state then it is acceptable otherwise it is not acceptable. NFA of the given string is as follow
2 min read
Practice problems on finite automata | Set 2
Que-1: Draw a deterministic and non-deterministic finite automate which either starts with 01 or end with 01 of a string containing 0, 1 in it, e.g., 01010100 but not 000111010. Explanation - Draw a DFA and NFA of same language whose strings only reach to the final state containing either 01 at start or at the end. If anything else is come then com
3 min read
Image encryption using cellular automata
To propose an image encryption system using one dimensional cellular automata for image encryption and decryption. Cellular automata can be corresponded with the essential cryptographic properties i.e. Balance, correlation-immune, nonlinearity, easy to implement in hardware. CA cryptosystems can give better performances compared to classic methods
4 min read
Designing Finite Automata from Regular Expression (Set 6)
Prerequisite: Finite automata, Regular expressions, grammar and language, Designing finite automata from Regular expression (Set 5) In the below article, we shall see some Designing of Finite Automata form the given Regular Expression- Regular Expression 1: Regular language, L1 = a(a+b)* The language of the given RE is, {aaa, aba, baa, bba} Strings
3 min read
Finite Automata with Output (Set 6)
Prerequisite: Mealy and Moore Machines, Difference between Mealy machine and Moore machine In this article, we will see some designing of Finite Automata with Output, i.e., Moore and Mealy machines. Problem: Construction of the machines that take set of all string over {0, 1} as input and produce 'A' as output if the input contains '101' as the sub
2 min read
Finite Automata with Output (Set 5)
Prerequisite: Mealy and Moore Machines, Difference between Mealy machine and Moore machine In this article, we will see some designing of Finite Automata with Output i.e, Moore and Mealy machines. Problem: Construction of the machines that take set of all string over {0, 1} as input and produce 'A' as output if the input contains '1' as the substri
2 min read
Designing Deterministic Finite Automata (Set 5)
Prerequisite: Designing finite automata In this article, we will see some designing of Deterministic Finite Automata (DFA). Problem-1: Construction of a minimal DFA accepting set of strings over {a, b} in which every 'a' is followed by a 'bb'. Explanation: The desired language will be like: L1 = {ε, abb, abbabb, bbbbabb, abbabbabbabbabbbb,
3 min read
Designing Deterministic Finite Automata (Set 9)
Prerequisite: Designing finite automata In this article, we will see some designing of Deterministic Finite Automata (DFA). Problem-1: Construction of a minimal DFA accepting a set of strings over {a, b} in which {abwa / wε{a, b}*}. Here 'w' is the substring containing alphabets over any number of 'a' and 'b' ranging from zero to infinity.
4 min read
Designing Deterministic Finite Automata (Set 6)
Prerequisite: Designing finite automata In this article, we will see some designing of Deterministic Finite Automata (DFA). Problem-1: Construction of a minimal DFA accepting set of strings over {a, b} in which anbm, where n and m is greater than or equal to 1. Explanation: The desired language will be like: L1 = {ab, aab, abb, aabb, aaabbb, aaabbb
3 min read
Finite Automata with Output (Set 3)
Prerequisite: Mealy and Moore Machines, Difference between Mealy machine and Moore machine In this article, we will see some designing of Finite Automata with Output i.e, Moore and Mealy machines. Problem: Construction of the machines that take set of all string over {a, b} as input and count number of substring 'a'. That is here we have, Ε
2 min read
Automata Theory | Set 7
These questions for practice purpose for GATE CS Exam. Ques-1: Consider L= {(TM) | TM is the Turing machine that halts on all input and L(TM)= L' for some undecidable language L'}. Here, (TM) is the encoding of a Turing machine as a string over alphabet {0, 1} then L is: (A) decidable and recursively enumerable (B) decidable and recursive (C) decid
3 min read
Automata Theory | Set 8
These questions for practice purpose for GATE CS Exam. Ques-1: Which one of the following language is Regular? (A) {wxwR | w,x ∈ (a+b)+} (B) {wxwR | w ∈ (a+b)*, x ∈ {a,b}} (C) {wwRx | w,x ∈ (a+b)+} (D) {wwR | w ∈ (a+b)*} Explanation: (A) It is correct, since this language can form regular expression which is {{ a(a + b)+a } + {b(a + b)+b}}, i.e., s
2 min read
Finite Automata with Output (Set 11)
Prerequisite: Mealy and Moore Machines, Difference between Mealy machine and Moore machine In this article, we will see some designing of Finite Automata with Output i.e, Moore and Mealy machines. Problem: Construction of the machines that take the binary number {0, 1} as input and produce 1's complement of that number as output. Here the assumptio
4 min read
Designing Finite Automata from Regular Expression (Set 2)
Prerequisite: Finite automata, Regular expressions, grammar and language. Designing finite automata from Regular expression In the below article, we shall see some Designing of Finite Automata form the given Regular Expression- Regular Expression 1: Φ (Phi). The language of the given RE is L1 = {} i.e, empty string. Its finite automata will be
3 min read
Article Tags :
three90RightbarBannerImg