/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none} Q3E Answer each part for the followi... [FREE SOLUTION] | 91Ó°ÊÓ

91Ó°ÊÓ

Answer each part for the following context-free grammar G

R→XRX|SS→aTb|bTaT→XTX|X|εX→a|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: T⇒aba.
  7. True or False: T⇒∗aba.
  8. True or False:T⇒T .
  9. True or False: T⇒∗T.
  10. True or False:XXX⇒∗aba .
  11. True or False: X⇒∗aba
  12. True or False:role="math" localid="1660812124187" T⇒∗XX.
  13. True or False: T⇒∗XXX.
  14. True or False: S⇒∗ε.
  15. Give a description in English of L(G) .

Short Answer

Expert verified
  1. V={R,X,S,T}
  2. {a,b}
  3. R
  4. Three strings inL(G) areab ,ba , and aab.
  5. Three strings are not inL(G) area , b, and ε.
  6. False.
  7. True.
  8. False.
  9. True.
  10. True.
  11. False.
  12. True.
  13. True.
  14. False.
  15. L(G)consists of all strings over aandb that are not palindromes.

Step by step solution

01

Define the context-free Grammar

Context-free grammar is a notation used for describing languages. It is more powerful than finite automata or Regular expressions.

02

Determine the variable of G

(a)

The capital letters are called variables because the value of that alphabet changes by replacing the productions.

Thus, the variables in the given grammar are,V={R,X,S,T}.

Therefore, the variables are:V={R,X,S,T}

03

Determine the terminals of G.

(b)

The letters which are represented in small are called terminals. Thus, the terminals in the given grammar are, {a,b}

Hence, the terminals are{a,b}

04

Determine the start variable of G

(c)

The special nonterminal symbol which appears in the initial string generated by the given grammar.

Hence, the start variable is R.

05

Determine the three strings in L(G) .

(d)

The three strings in languageL(G)of grammar Gare as follows,

1. ab

Proof:

Consider the production R→S,Replace Swith aTbfrom the production R→aTb.Replace Twith ε from the production R→²¹Îµ²ú. The resulting string is R→ab.

Therefore, the string is present in .

2. ba

Proof:

Consider the productionR→S,ReplaceS with bTafrom the production R→bTa. Replace Twith εfrom the production R→²úε²¹.The resulting string isR→ba .

Therefore, the string is present in.

3. aab

Proof:

Consider the productionR→S,ReplaceS withaTb from the productionR→aTb .Replace Twith xfrom the production R→aXb. Replacex witha from the productionX→a .The resulting string is R→aab.

Hence, the three strings areab,ba andaab.

06

Determine the three strings that are not in L(G) . 

(e)

The three strings not in L(G) are

aaa,bab , bbb

Proof:

Substitute the production rules in variables, starting from the starts symbol. The above four strings cannot be obtained.

Hence, the strings aaa, bab,andbbb arenot in L (G).

07

Determine if  T⇒aba is True or False 

(f)

T⇒aba

False because there is no rule which translates Tdirectly to aba.

Hence, the given statement is false.

08

Determine if T⇒∗aba is True or False

(g)

T⇒∗aba, can be produced by the production T→XTX. Thus, the given statement isTrue.

Hence,T⇒∗aba is true.

09

Determine If T⇒T is True or False

(h)

The grammar has no rule T⇒T.

Hence,T⇒T is false.

10

Determine if T⇒∗T is True or False

(i)

The production T⇒∗Tcan be derived from the given grammar. Thus, the given statement is True.

Hence,T⇒∗T is True.

11

Determine if XXX⇒∗aba is True or False

(j)

The given production is true because each Xcan be substituted with a or b.

Hence,XXX⇒∗aba is true.

12

Determine if X⇒∗aba  is True or False. 

(k)

The given rule is false since Xcan only become a or b.

Hence,X⇒∗aba is false.

13

Determine if T⇒∗XX is True or False.

(l)

The given rule is true because asT can be substituted with an empty string ∈.

Hence, T⇒∗XXis true.

14

Determine if T⇒XTX⇒XXX is True or False.

(m)

The given rule is true, since T⇒XTX⇒XXXcan be substituted with X. X⇒∗aba.

Hence, T⇒∗XXXis true.

15

Determine if S⇒∗∈  is True or False.

(n)

False because any string derived from Shas at least one occurrence of a and b.

Hence, role="math" localid="1660815034121" S⇒*∈is false.

16

Write description of language in English 

(o)

Since from Rget any number of X'on both sides, L(G)={a,b)∗\(a∗∪b∗). It produces strings of the form XnSXnfor value of ngreater than or equal to 0.

Therefore, L(G) consists of all strings overa and bthat are not palindromes.

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 91Ó°ÊÓ!

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

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.