0% found this document useful (0 votes)
45 views8 pages

Pushdown Automaton

A pushdown automaton (PDA) is a nondeterministic finite state automaton that uses a stack to perform transitions. A PDA is defined as a 7-tuple that includes a finite set of states, input symbols, stack symbols, transition function, start state, initial stack symbol, and accepting states. The document then provides an example of a PDA that recognizes the context-free language of even-length palindromes over the alphabet {0,1}. It defines the PDA as a 7-tuple and includes the transition function and graphical representation. Finally, it presents two exercises to design PDAs for specific languages.

Uploaded by

Neha Mehndiratta
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views8 pages

Pushdown Automaton

A pushdown automaton (PDA) is a nondeterministic finite state automaton that uses a stack to perform transitions. A PDA is defined as a 7-tuple that includes a finite set of states, input symbols, stack symbols, transition function, start state, initial stack symbol, and accepting states. The document then provides an example of a PDA that recognizes the context-free language of even-length palindromes over the alphabet {0,1}. It defines the PDA as a 7-tuple and includes the transition function and graphical representation. Finally, it presents two exercises to design PDAs for specific languages.

Uploaded by

Neha Mehndiratta
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 8

Pushdown Automaton (PDA)

A Pushdown Automaton is a nondeterministic finite state automaton (NFA) that permits transitions and a stack.

Pushdown Automaton (PDA)


P = ( Q , , , ( qi , a, m ) { ( qk , n ),...}, q0 , 0 , F )
Q: A finite set of states. : A finite set of input symbols. : A finite stack alphabet. : The transition function with input: qi is a state in Q. a is a symbol in or a = (the empty string). m is a stack symbol, m . and the output is a finite set of pairs: qk the new state. n is the string of stack symbols that replaces m at the top of the stack. If n = , then the stack is popped. q0: The start state. 0 : Initially, the PDAs stack consists this symbol and nothing else. F : The set of accepting states.

Lwwr = {ww R | w (0 + 1)*} PDA Example:


The language, Lwwr, is the even-length palindromes over alphabet {0,1}. Lwwr is a Context-Free Language (CFL) generated by the grammar:

S 0 S 0 | 1S1 |
One PDA for Lwwr is given on the following slide...

PDA for Lwwr


1) 2)

P = ( Q , , , , q0 , 0 , F )

Q = {q0 , q1 , q2 , q3} = {0,1} = {0,1, 0 } F = {q3}


( q0 ,0, 0 ) ( q0 ,0 0 ) ( q0 ,1, 0 ) ( q0 ,1 0 )
( q0 ,0,0) ( q0 ,00) ( q0 ,0,1) ( q0 ,01) ( q0 ,1,0) ( q0 ,10) ( q0 ,1,1) ( q0 ,11)

3)

( q0 , , 0 ) ( q1 , 0 ) ( q0 , ,0) ( q1 ,0) ( q0 , ,1) ( q1 ,1)

4)
5) 6)

( q1 ,0,0) ( q1 , ) ( q1 ,1,1) ( q1 , )
( q1 , , 0 ) ( q2 , 0 )

( q2 , Read_Past_ End_Of_Inp ut , 0 ) ( q3 , 0 )

A Graphical Notation for PDAs


1. 2. 3. 4. 5.

The nodes correspond to the states of the PDA. An arrow labeled Start indicates the unique start state. Doubly circled states are accepting states. Edges correspond to transitions in the PDA as follows: An edge labeled (ai, m)/n from state q to state p means that (q, ai, m) contains the pair (p, n), perhaps among other pairs.

Graphical Notation for PDA of Lwwr


(0, 0)/00 (1, 0)/10 start (0, 0)/00 (0, 1)/01 (1, 0)/10 (1, 1)/11 (0,0)/ (1,1)/ (,0) / 0

(, 0) / 0 (, 0) / 0 (, 1) / 1 All possibilities that do not have explicit edges, have implicit edges that go to an implicit reject state.

q0

q1

q2

(EOF, 0) / 0

q3

This is a nondeterministic machine. Think of the machine as following all possible paths. Kill a path if it leads to a reject state. If any path leads to an accept state, then the machine accepts.

Exercise 1
Design a PDA that recognizes legal sequences of if and else statements in a C program. In the PDA, let i stands for if and e stands for else. Hint: There is a problem whenever the number of else statements in any prefix exceeds the number of if statements in that prefix.

Exercise 2
Design a PDA to accept the language:

{a b c | i = j or j = k }
i j k

You might also like