0

I am attempting to convert the following CFG to a pushdown automaton:

S → AS | A
A → 0A | 1B | 1
B → 0B | 0

I'm not really sure how to approach this problem, or the problem of CFG->PDA in general.

Qantas 94 Heavy
  • 15,750
  • 31
  • 68
  • 83
Dan9993
  • 1
  • 2
  • sounds like a homework. maybe try to review the textbook first? – Jason Hu Mar 31 '15 at 16:38
  • As a hint, the language of this grammar is regular, so you could build a finite automaton for it and then easily convert that to a PDA. – templatetypedef Mar 31 '15 at 16:47
  • It was an online homework problem I couldn't get, and the online explanation didn't give me much help. I was hoping someone could explain it. – Dan9993 Mar 31 '15 at 17:09
  • 1
    @Dan9993 [CFG to PDA Example](http://www.cse.msu.edu/~torng/Classes/Archives/cps360.98spring/Examples/CFGtoPDA/tsld001.htm) – Grijesh Chauhan Mar 31 '15 at 18:20

2 Answers2

1

Conversation of Context free grammar to Pushdown automata: Steps to convert CFG to Pushdown automata: Step-1:The first symbol on R.H.S. production must be a terminal symbol.

Step-2:Convert the given productions of CFG into GNF.

Step-3:The PDA will only have one state {q}.

Step-4:The initial symbol of CFG will be the initial symbol in the PDA.

Step-5:For non-terminal symbol, add the following rule: δ(q, ε, A) = (q, α)
Where the production rule is A → α.

Step-6:For each terminal symbols, add the following rule: δ(q, a, a) = (q, ε) for every terminal symbol

0

You may use JFlap application to do it for you. http://www.jflap.org/ Beyond this there are several other interesting functionalyties in that application that will help you study formal languages. I've been using it for about two weeks and I'm loving it.

Roberto Santos
  • 606
  • 1
  • 7
  • 11