1 / 14

Pushdown Automata – Simplifying the Grammar

Pushdown Automata – Simplifying the Grammar. Lecture 20 Section 2.2 Fri, Oct 5, 2007. The Grammar Rules. We now have the grammar rules A pp  A pp A pp A pq  A pp A pq A pq  A pq A qq A pr  A pp A pr A pr  A pq A qr A pr  A pr A rr A qq  A qq A qq. The Grammar Rules.

zavad
Download Presentation

Pushdown Automata – Simplifying the Grammar

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 – Simplifying the Grammar Lecture 20 Section 2.2 Fri, Oct 5, 2007

  2. The Grammar Rules • We now have the grammar rules • AppAppApp • ApqAppApq • ApqApqAqq • AprAppApr • AprApqAqr • AprAprArr • AqqAqqAqq

  3. The Grammar Rules • AqrAqqAqr • AqrAqrArr • ArrArrArr • AprAqq • AqqaAqqb • App • Aqq • Arr

  4. The Grammar • The start symbol is Apr.

  5. Simplifying the Grammar • We may simplify these grammar rules considerably. • Eliminate any rule involving a variable that never appears on the left. • Eliminate any rule involving a variable, other than the start symbol, that never appears on the right.

  6. Simplifying the Grammar • Eliminate any rule involving a variable that is purely recursive. • Eliminate any unnecessary unit rules. • Use common sense to eliminate any other rules that are useless.

  7. Simplifying the Grammar • The grammar rules are reduced to • AppAppApp |  • AprAppApr | AprArr | Aqq • AqqAqqAqq | aAqqb |  • ArrArrArr | 

  8. Simplifying the Grammar • Then we notice that the rules • AppAppApp |  • ArrArrArr |  are useless since the only other choice for App and Arr is . • We should eliminate them and replace App and Arr with  everywhere they occur.

  9. Simplifying the Grammar • Now the grammar rules are reduced to • AprApr | Apr | Aqq • AqqAqqAqq | aAqqb | 

  10. Simplifying the Grammar • Now it is obvious that the rule • AprApr is pointless, so eliminate it. • We now have • AprAqq • AqqAqqAqq | aAqqb | 

  11. Simplifying the Grammar • Now it is obvious that the unit rule • AprAqq serves no purpose. • Eliminate it, making Aqq the new start symbol.

  12. Simplifying the Grammar • We now have • AqqAqqAqq | aAqqb |  or, more simply, • SSS | aSb | 

  13. a,; a b, a;  , ;  , ; $ , $;  p q r s Exercise • Find a context-free grammar for the language of the PDA

  14. Exercise • Find a context-free grammar for the language of the PDA (,; ( ),(;  a, ;  , ; $ , $;  p q r s +, ; 

More Related