1 / 8

Pushdown Automaton (PDA)

Pushdown Automaton (PDA). A Pushdown Automaton is a nondeterministic finite state automaton (NFA) that permits ε -transitions and a stack. Pushdown Automaton (PDA). Q : A finite set of states. S : A finite set of input symbols. G : A finite stack alphabet.

admon
Télécharger la présentation

Pushdown Automaton (PDA)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Pushdown Automaton (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). • tm is a stack symbol, tmÎG. • and the output is a finite set of pairs: • qk the new state. • tn is the string of stack symbols that replaces tm at the top of the stack. If tn = e, then the stack is popped. • q0: The start state. • t0 : Initially, the PDA’s stack consists this symbol and nothing else. • F : The set of accepting states.

  3. 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: One PDA for Lwwr is given on the following slide...

  4. PDA for Lwwr

  5. 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 (ai, tm)/tn from state q to state p means that d(q, ai, tm) contains the pair (p, tn), perhaps among other pairs.

  6. q0 q1 q2 q3 Graphical Notation for PDA of Lwwr (0, 0)/00 (0, 1)/01 (1, 0)/10 (1, 1)/11 (0,0)/ε (1,1)/ε (0, t0)/0t0 (1, t0)/1t0 start (ε,t0) / t0 (ε, t0) / t0 (ε, 0) / 0 (ε, 1) / 1 (EOF,t0) / t0 All possibilities that do not have explicit edges, have implicit edges that go to an implicit reject state. • 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.

  7. 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.

  8. Exercise 2 Design a PDA to accept the language:

More Related