• date post

10-Jan-2016
• Category

## Documents

• view

80

3

Embed Size (px)

description

Pushdown Automata (PDA). CSE-501 Formal Language & Automata Theory Aug-Dec,2010. ALAK ROY. Assistant Professor Dept. of CSE NIT Agartala. Pushdown Automata (PDA). Informally: Think of an ε -NFA with the additional power that it can manipulate a stack. - PowerPoint PPT Presentation

### Transcript of Pushdown Automata (PDA)

• PUSHDOWN AUTOMATA (PDA)ALAK ROY.Assistant ProfessorDept. of CSENIT AgartalaCSE-501 FORMAL LANGUAGE & AUTOMATA THEORYAug-Dec,2010

• *PUSHDOWN AUTOMATA (PDA)Informally:Think of an -NFA with the additional power that it can manipulate a stack.Transitions are modified to accommodate stack operations.

Questions:What is a stack?How does a stack help?

Why PDA?A DFA can remember only a finite amount of information, whereas a PDA can remember an infinite amount of (certain types of) information.

• *

Example:

{0n1n | 0=

• *

In a DFA, each state remembers a finite amount of information.

To get {0n1n | 0n} with a DFA would require an infinite number of states using the preceding technique.

An infinite stack solves the problem for {0n1n | 0n} as follows:Read all 0s and place them on a stackRead all 1s and match with the corresponding 0s on the stack

Only need two states to do this in a PDA

Similarly for {0n1m0n+m | n,m0}

• PDA MODEL

• CHARACTERISTIC OF PDAPDS (Pushdown Stack)

• *PDABeing nondeterministic, the PDA can have a choice of next moves.

Its moves are determined by:The current state (of its NFA),The current input symbol (or ), and The current symbol on top of its stack.

In each choice, the PDA can:Change state, and alsoReplace the top symbol on the stack by a sequence of zero or more symbols.Zero symbols = pop.Many symbols = sequence of pushes.

• *FORMAL DEFINITION OF A PDAA pushdown automaton (PDA) is a seven-tuple:

M = (Q, , , , q0, z0, F)

QA finite set of statesA finite input alphabetA finite stack alphabetq0The initial/starting state, q0 is in Qz0A starting stack symbol, is in FA set of final/accepting states, which is a subset of QA transition function, where : Q x ( U {}) x > finite subsets of Q x *

• *Consider the various parts of :

Q x ( U {}) x > finite subsets of Q x *

Q on the LHS means that at each step in a computation, a PDA must consider its current state. on the LHS means that at each step in a computation, a PDA must consider the symbol on top of its stack. U {} on the LHS means that at each step in a computation, a PDA may or may not consider the current input symbol, i.e., it may have epsilon transitions.

Finite subsets on the RHS means that at each step in a computation, a PDA will have several options.Q on the RHS means that each option specifies a new state.* on the RHS means that each option specifies zero or more stack symbols that will replace the top stack symbol.

• *CONVENTIONSa, b, are input symbols.But sometimes we allow as a possible value., X, Y, Z are stack symbols., w, x, y, z are strings of input symbols., , are strings of stack symbols.

• *THE TRANSITION FUNCTIONTakes three arguments:A state, in Q.An input, which is either a symbol in or .A stack symbol in .(q, a, Z) is a set of zero or more actions of the form (p, ).p is a state; is a string of stack symbols.

• *ACTIONS OF THE PDAIf (q, a, Z) contains (p, ) among its actions, then one thing the PDA can do in state q, with a at the front of the input, and Z on top of the stack is:Change the state to p.Remove a from the front of the input (but a may be ).Replace Z on the top of the stack by . (or Pop Z, Push )

• *Two types of PDA transitions:

(q, a, z) = {(p1, 1), (p2, 2),, (pm, m)}

Current state is qCurrent input symbol is aSymbol currently on top of the stack zMove to state pi from qReplace z with i on the stack (leftmost symbol on top)Move the input head to the next input symbol

:

qp1p2pma/z/ 1a/z/ 2a/z/ m

• *Two types of PDA transitions:

(q, , z) = {(p1, 1), (p2, 2),, (pm, m)}

Current state is qCurrent input symbol is not consideredSymbol currently on top of the stack zMove to state pi from qReplace z with i on the stack (leftmost symbol on top)No input symbol is read

:

qp1p2pm/z/ 1/z/ 2/z/ m

• *EXAMPLE: PDADesign a PDA to accept {0n1n | n > 1}.The states:q = start state. We are in state q if we have seen only 0s so far.p = weve seen at least one 1 and may now proceed only if the inputs are 1s.f = final state; accept.

• *EXAMPLE: PDA (2)The stack symbols:Z0 = start symbol. Also marks the bottom of the stack, so we know when we have counted the same number of 1s as 0s.X = marker, used to count the number of 0s seen on the input.

• *EXAMPLE: PDA (3)The transitions:(q, 0, Z0) = {(q, XZ0)}.(q, 0, X) = {(q, XX)}. These two rules cause one X to be pushed onto the stack for each 0 read from the input.(q, 1, X) = {(p, )}. When we see a 1, go to state p and pop one X.(p, 1, X) = {(p, )}. Pop one X per 1.(p, , Z0) = {(f, Z0)}. Accept at bottom.

• ACTIONS OF THE EXAMPLE PDAq 0 0 0 1 1 1Z0

• ACTIONS OF THE EXAMPLE PDAq 0 0 1 1 1XZ0

• ACTIONS OF THE EXAMPLE PDAq 0 1 1 1XXZ0

• ACTIONS OF THE EXAMPLE PDAq1 1 1XXXZ0

• *ACTIONS OF THE EXAMPLE PDAp1 1XXZ0

• ACTIONS OF THE EXAMPLE PDAp1XZ0

• ACTIONS OF THE EXAMPLE PDApZ0

• ACTIONS OF THE EXAMPLE PDAfZ0

• THANK YOU

***************