1 / 6

Pushdown Automata and Context-Free Grammars

Pushdown Automata and Context-Free Grammars. Reading: 7.2 & 7.3. CFG(L) = PDA(L). Any context-free language has a pushdown automata that accepts the language. Any context-free language can be written in Greibach Normal Form. (All productions of the form

soleil
Download Presentation

Pushdown Automata and Context-Free Grammars

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 Automata and Context-Free Grammars Reading: 7.2 & 7.3

  2. CFG(L) = PDA(L) • Any context-free language has a pushdown automata that accepts the language. • Any context-free language can be written in Greibach Normal Form. (All productions of the form A -> aX where X is a string of variables.)

  3. PDA from Greibach • First, push the start symbol onto the stack. δ(q0,λ,Z) = {(q1,SZ)} • Any productions of the form A->a: δ(q1,a,A) = (q1, λ) • Any productions of the form A->aX: δ(q1,a,A) = {(q1,X)} • Finally, recognize the accept state: δ(q1,λ,Z) = {(q2, λ)}

  4. Example S -> aSA | a A -> bB B -> b Yields: δ(q0,λ,Z) = {(q1,SZ)} δ(q1,a,S) = {(q1, λ), (q1, SA)} δ(q1,b,A) = {(q1, B)} δ(q1,b,B) = {(q1, λ)} δ(q1, λ,Z) = (q2, λ)

  5. Deterministic PDA • At each step, there is no choice for the move: • Every δ(q,a,b) contains at most one element • If δ(q,λ,b) is not empty, then δ(q,c,b) must be empty for every c in the alphabet • Note: Lambda transitions are allowed, but it is always clear when to take them.

  6. Theoretical Results • Every CFG can be written in Greibach • There is an algorithm (in book) to turn PDA into a CFG. • A language accepted by a deterministic pushdown automata is called a deterministic context-free language. • NPDA’s are more powerful than DPDA’s. • Not every context-free language is a deterministic context-free language!

More Related