1 / 69

… NPDAs continued

… NPDAs continued. Pushing Strings. Pop symbol. Input symbol. Push string. Example:. input. pushed string. stack. top. Push. Another NPDA example. NPDA. Execution Example:. Time 0. Input. Stack. current state. Time 1. Input. Stack. Time 3. Input. Stack. Time 4. Input.

skylar
Download Presentation

… NPDAs continued

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. … NPDAs continued

  2. Pushing Strings Pop symbol Input symbol Push string

  3. Example: input pushed string stack top Push

  4. Another NPDA example NPDA

  5. Execution Example: Time 0 Input Stack current state

  6. Time 1 Input Stack

  7. Time 3 Input Stack

  8. Time 4 Input Stack

  9. Time 5 Input Stack

  10. Time 6 Input Stack

  11. Time 7 Input Stack

  12. Time 8 Input Stack accept

  13. Formalities for NPDAs

  14. Transition function:

  15. Transition function:

  16. Formal Definition Non-Deterministic Pushdown Automaton NPDA Final states States Input alphabet Stack start symbol Transition function Stack alphabet

  17. Instantaneous Description Current state Current stack contents Remaining input

  18. Example: Instantaneous Description Input Time 4: Stack

  19. Example: Instantaneous Description Input Time 5: Stack

  20. We write: Time 4 Time 5

  21. A computation:

  22. For convenience we write:

  23. Formal Definition Language of NPDA : Initial state Final state

  24. Example: NPDA :

  25. NPDA :

  26. Therefore: NPDA :

  27. NPDAs Accept Context-Free Languages

  28. Theorem: Context-Free Languages (Grammars) Languages Accepted by NPDAs

  29. Proof - Step 1: Context-Free Languages (Grammars) Languages Accepted by NPDAs Convert any context-free grammar to a NPDA with:

  30. Proof - Step 2: Context-Free Languages (Grammars) Languages Accepted by NPDAs Convert any NPDA to a context-free grammar with:

  31. ConvertingContext-Free Grammarsto NPDAs

  32. An example grammar: What is the equivalent NPDA?

  33. Grammar: NPDA:

  34. The NPDA simulates leftmost derivations of the grammar L(Grammar) = L(NPDA)

  35. Grammar: A leftmost derivation:

  36. NPDA execution: Time 0 Input Stack current state

  37. Time 1 Input Stack

  38. Time 2 Input Stack

  39. Time 3 Input Stack

  40. Time 4 Input Stack

  41. Time 5 Input Stack

  42. Time 6 Input Stack

  43. Time 7 Input Stack

  44. Time 8 Input Stack

  45. Time 9 Input Stack

  46. Time 10 Input Stack accept

  47. In general: Given any grammar We can construct a NPDA With

  48. Constructing NPDA from grammar : For any production For any terminal

  49. Grammar generates string if and only if NPDA accepts

  50. Therefore: For any context-free language there is an NPDA that accepts the same language

More Related