Example:

1 / 3

# Example: - PowerPoint PPT Presentation

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.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about 'Example:' - waylon

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
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 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

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

PDA = NFA + a stack (infinite memory)

A possible way: “divide and conquer”

Lx = { aibj; i>j }

LY = { aibj; i

e, e /e

Combine both …