Presentation is loading. Please wait.

Presentation is loading. Please wait.

Pushdown Automata - like NFA-  but also has a stack - transition takes the current state, the current input symbol, and the top-of-the-stack symbol (which.

Similar presentations


Presentation on theme: "Pushdown Automata - like NFA-  but also has a stack - transition takes the current state, the current input symbol, and the top-of-the-stack symbol (which."— Presentation transcript:

1 Pushdown Automata - like NFA-  but also has a stack - transition takes the current state, the current input symbol, and the top-of-the-stack symbol (which is removed from the stack) and returns a state and a string to place in the stack - the automaton starts in the initial state, reading the first symbol on the tape, and having a special initial symbol on the stack - automaton accepts a string x if, after reading all of x, it can get to an accepting state (the stack content does not matter) - if the stack is empty, the automaton is stuck [Section 7.1]

2 Pushdown Automata Example: L = { a k b k | k ¸ 0 } [Section 7.1]

3 Pushdown Automata Example: L = { w 2 {a,b}* | w is an even-length palindrome } [Section 7.1]

4 Pushdown Automata [Section 7.2] Def: A pushdown automaton (PDA) is a 7-tuple (Q, , ,q 0,Z 0,A,  ) where - Q is a finite set of states -  is a finite input alphabet -  is a finite stack alphabet - q 0 2 Q is the initial state - Z 0 2  is the initial stack symbol - A µ Q is the set of accepting states -  is the transition function from ______________ to finite subsets of Q £  *

5 Pushdown Automata [Section 7.2] Def: Let M = (Q, , ,q 0,Z 0,A,  ) be a PDA. A configuration is a triple (p,x,  ) where p is the current state, x is the rest of the input (the yet-unread part), and  is the content of the stack (the top is on the left). We write (p,x,  ) ` M (q,y,  ) if we can get from the configuration (p,x,  ) to the configuration (q,y,  ) using one transition of M. Similarly we write (p,x,  ) ` M * (q,y,  ) if we can get from (p,x,  ) to (q,y,  ) through a finite sequence of transitions of M. The language accepted by M : L(M) = { x 2  * | ________________________ }

6 Deterministic Pushdown Automata [Section 7.3] Def: Let M = (Q, , ,q 0,Z 0,A,  ) be a PDA. M is deterministic (DPDA) if A language L is a deterministic context-free language (DCFL) if there exists a DPDA accepting L.

7 Deterministic Pushdown Automata [Section 7.3] Example: Give a DPDA for L = { a k b k | k ¸ 1 }. Can you give a DPDA for L 2 = { a k b k | k ¸ 0 } ?

8 Determinism vs. Nondeterminism [Section 7.3] For finite automata : For PDA : There exists a language which can be accepted by a PDA but not by a DPDA !

9 Determinism vs. Nondeterminism [Section 7.3] Example: Is the language given by S  SS | (S) |  a DCFL ?

10 Determinism vs. Nondeterminism [Section 7.3] Example: { x 2 {a,b}* | number of a’s in x = number of b’s in x }

11 Determinism vs. Nondeterminism [Section 7.3] Example: { x 2 {a,b}* | (numb. a’s in x) = 2 (numb. b’s in x) }

12 CFG vs. PDA [Sections 7.4 and 7.5] It is possible to show that every language generated by a CFG can be accepted by a PDA and vice versa. Thm: Let G = (V,  G,S,P) be a CFG. Then there exists a PDA M = (Q,  M, ,q 0,Z 0,A,  ) such that L(M) = L(G). Thm: Let M = (Q,  M, ,q 0,Z 0,A,  ) be a PDA. Then there exists a CFG G = (V,  G,S,P) such that L(G) = L(M). Which one is easier to prove ?

13 CFG vs. PDA [Section 7.4] Thm: Let G = (V,  G,S,P) be a CFG. Then there exists a PDA M = (Q,  M, ,q 0,Z 0,A,  ) such that L(M) = L(G). Example: S  S + T | T T  T * R | R R  (S) | x


Download ppt "Pushdown Automata - like NFA-  but also has a stack - transition takes the current state, the current input symbol, and the top-of-the-stack symbol (which."

Similar presentations


Ads by Google