480 likes | 1.5k Views
Pushdown Automata. PDA. Informally: A PDA is an ε-NFA with a stack. Transitions are modified to accommodate stack operations. A DFA can “remember” only a finite amount of information, whereas a PDA can “remember” an infinite amount of (certain types of) information. PDA. PDA.
E N D
PDA • Informally: • A PDA is an ε-NFA with a stack. • Transitions are modified to accommodate stack operations. • A DFA can “remember” only a finite amount of information, whereas a PDA can “remember” an infinite amount of (certain types of) information.
PDA • In one transition, the PDA
Q: A finite set of states. • S : A finite set of input symbols. • G: A finite stack alphabet. • d: The transition function with input: • qi is a state in Q. • a is a symbol in S or a = e (the empty string). • X is a stack symbol, X ÎG. • and the output is a finite set of pairs: • p the new state. • γis the string of stack symbols that replaces X at the top of the stack. • q0: The start state. • Z0: Initially, the PDA’s stack consists this symbol and nothing else. • F : The set of accepting states. • PDA is a seven-tuple: M = (Q, Σ, G, δ, q0, Z0, F)
PDA Example: The language, Lwwr, is the even-length palindromes over alphabet {0,1}. Let’s design a PDA for this language.
A Graphical Notation for PDA’s • 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 a, X/ αfrom state q to state p means that d(q, a, X)contains the pair (p, α), perhaps among other pairs. The only other thing that the diagram does not tell us is which stack symbol is the start symbol. Conventionally, it is Z0, unless we indicate otherwise.
q0 q1 q2 PDA for wwr (0, 0)/00 (0, 1)/01 (1, 0)/10 (1, 1)/11 0,0/ε 1,1/ε 0, Z0/0Z0 1, Z0/1Z0 start ε, Z0/ Z0 ε, Z0/ Z0 ε, 0/ 0 ε, 1 / 1
Configurations • A configuration fully describes the current “state” of the PDA. • The current state q. • The remaining input w. • The current stack contents γ. • Thus, a configuration is a triple (q, w, γ) (Q, *, *). Such a triple is called an Instantaneous Description(ID) of the pushdown automata.
Acceptance of 1111 by the PDA • q0,1111,Z0q0, 111, 1Z0 q0, 11, 11Z0 q0, 11, 11Z0 q1, 11, 11Z0 q1, 1, 1Z0 q1, ε, Z0 q2, ε, Z0 Accepted.