1 / 3

Example:

Example:. Given the following CFG S  X | Y X  aXb | aX | a Y  aYb | Yb | b (1) L(G) = ? (2) Design an equivalent PDA for it. Σ ={a, b}. Solution: L(S). S  X | Y X  a X b | a X | a Y  a Y b | Y b | b.

waylon
Download Presentation

Example:

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. Example: • Given the following CFG S  X | Y X  aXb | aX | a Y  aYb | Yb | b • (1) L(G) = ? • (2) Design an equivalent PDA for it. Σ={a, b}

  2. Solution: L(S) S  X |Y X aXb | aX | a Y aYb | Yb | b Try to write some strings generated by it: SXaXbaaXbbaaaXbbaaaabb SYaYbaYbbaaYbbbaabbbb more a’s than b’s more b’s than a’s • Observations: • Start from S, we can enter two States X & Y, and X, Y are “independent”; • In X state, always more a are generated; • In Y state, always more b are generated. Ls = Lx U Ly L(S) = { aibj; i≠j } Lx = { aibj; i>j } Lx = { aibj; i<j }

  3. a,e/A b,A/e b,$/$ a,e/A b,A/e e,A/e e,$/e e,$/e e,e/e e,e/$ e,e/$ e,e/e e,A/e b,$/$ q0 q’0 q1 q’1 q2 q’2 q3 q’3 Solution: PDA L(S) = { aibj; i≠j } S  X | Y X aXb | aX | a Y aYb | Yb | b = { aibj; i>j } U { aibj; i<j } PDA = NFA + a stack (infinite memory) A possible way: “divide and conquer” Lx = { aibj; i>j } LY = { aibj; i<j } e, e /e Combine both …

More Related