Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Convert the following CFG into an equivalent CFG in Chomsky normal form, using the procedure given in Theorem 2.9.

ABAB|B|εB00|ε

Short Answer

Expert verified

Answer

SBD|BB|AB|CC|BA|εABD|BB|AB|CC|BABCCC0DAB

Step by step solution

01

Define Chomsky Normal Form (CNF)

In theory of computation, context free grammar (CFG) generates the possible strings in a language. CFG is in Chomsky normal form (CNF) if the production rules in it are of the following forms:

ABCAa

02

Add a new start symbol S

SAABAB|B|εB00|ε

03

Remove ε-productions.

The two ε-productions are:

AεBεRemove,AεSA|εABAB|BB00|εRemoveBεSA|εABAB|AB|BA|BB|B|εB00Aεiscreatedagain.RemoveAεABAB|BB|AB|B|BA|εB00RemoveAεagain.SA|εABAB|BB|AB|B|BAB00

04

Remove the unit productions.

The two-unit productions are:

SARemoveSA.SBAB|BB|AB|B|BA|εABAB|BB|AB|B|BAB00RemoveSB.SBAB|BB|AB|00|BA|εABAB|BB|AB|B|BA3B00RemoveABSBAB|BB|AB|00|BA|εABAB|BB|AB|00|BAB00

05

Add new variables

SBD|BB|AB|CC|BA|εABD|BB|AB|CC|BABCCC0DAB

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Let C=WWRW0,1*.. Prove that C is not a DCFL. (Hint: Suppose that when some DPDA P is started in state q with symbol x on the top of its stack, P never pops its stack below x, no matter what input string P reads from that point on. In that case, the contents of P’s stack at that point cannot affect its subsequent behaviour, so P’s subsequent behavior can depend only on q and x).

Question: Convert the following CFG into an equivalent CFG in Chomsky normal form, using the procedure given in Theorem 2.9.

ABAB|B|εB00|ε

We defined the rotational closure of language Ato be RC(A)={yx|xyA} . Show that the class of CFLs is closed under rotational closure

Give context-free grammars that generate the following languages. In all parts, the alphabet is {0,1}.

role="math" localid="1660714062992" a.{wwcontainsatleastthree1s}b.{wwstartsandendswiththesamesymbol}c.{wthelengthofwisodd}d.{wthelengthofwisoddanditsmiddlesymbolisa0}e.{ww=wR,thatis,wisapalindrome}f.Theemptyset.

Answer each part for the following context-free grammar G

RXRX|SSaTb|bTaTXTX|X|εXa|b

  1. What are the variables of G?
  2. What are the terminals of G?
  3. Which is the start variable of G?
  4. Give three strings in L(G).
  5. Give three strings not inL(G) .
  6. True or False: Taba.
  7. True or False: Taba.
  8. True or False:TT .
  9. True or False: TT.
  10. True or False:XXXaba .
  11. True or False: Xaba
  12. True or False:role="math" localid="1660812124187" TXX.
  13. True or False: TXXX.
  14. True or False: Sε.
  15. Give a description in English of L(G) .
See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free