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

Construct phrase-structure grammars to generate each of these sets.

a) \(\left\{ {\left. {{{\bf{0}}^{\bf{n}}}} \right|{\bf{n}} \ge {\bf{0}}} \right\}\)

b) \(\left\{ {\left. {{{\bf{1}}^{\bf{n}}}{\bf{0}}} \right|{\bf{n}} \ge {\bf{0}}} \right\}\)

c) \(\left\{ {\left. {{{\left( {{\bf{000}}} \right)}^{\bf{n}}}} \right|{\bf{n}} \ge {\bf{0}}} \right\}\)

Short Answer

Expert verified

a) The phase structure grammar is \(S \to SS,S \to 0,S \to {\rm{\lambda }}\).

b) The phase structure grammar is \(S \to A0,A \to AA,A \to {\rm{1,A}} \to {\rm{\lambda }}\).

c) The phase structure grammar is \(S \to SS,S \to 000,S \to {\rm{\lambda }}\).

Step by step solution

01

Let’s construct a phrase-structure grammar

Let\(G{\bf{ }} = {\bf{ }}\left( {{\rm{V, T, S, P}}} \right)\)be the phrase structure grammar that produces all signed decimal numbers. It consists of a sign, either + or -, a non-negative integer, and a decimal fraction, which can either be the empty string or a decimal point followed by a positive integer.

02

Construct phrase-structure grammars to generate \(\left\{ {\left. {{{\bf{0}}^{\bf{n}}}} \right|{\bf{n}} \ge {\bf{0}}} \right\}\).

a)

\(L = \left\{ {\left. {{0^n}} \right|n \ge 0} \right\}\).

Then, \(G{\bf{ }} = {\bf{ }}\left( {V,{\bf{ }}T,{\bf{ }}S,{\bf{ }}P} \right)\) is a phrase structure grammar which generates the language L if \(V{\bf{ }} = {\bf{ }}\left\{ {0,{\bf{ }}S} \right\},{\bf{ }}T{\bf{ }} = {\bf{ }}\left( 0 \right)\), S is the starting symbol and the productions are

Hence, the phase structure grammar for the set is \(S \to SS,S \to 0,S \to {\rm{\lambda }}\).

03

Construct phrase-structure grammars to generate \(\left\{ {{{\bf{1}}^{\bf{n}}}{\bf{0|n}} \ge {\bf{0}}} \right\}\). b)

\(L = \left\{ {\left. {{1^n}0} \right|n \ge 0} \right\}\)

Then, \(G{\bf{ }} = {\bf{ }}\left( {V,{\bf{ }}T,{\bf{ }}S,{\bf{ }}P} \right)\) is a phrase structure grammar which generates the language L if \(V{\bf{ }} = {\bf{ }}\left\{ {1,{\bf{ }}0,{\bf{ }}S,{\bf{ }}A} \right\},{\bf{ }}T{\bf{ }} = {\bf{ }}\left\{ {1,{\bf{ }}0} \right\}\), S is the starting symbol and the productions are

Hence, the phase structure grammar for the set is \(S \to A0,A \to AA,A \to {\rm{1,A}} \to {\rm{\lambda }}\).

04

Construct phrase-structure grammars to generate \(\left\{ {\left. {{{\left( {{\bf{000}}} \right)}^{\bf{n}}}} \right|{\bf{n}} \ge {\bf{0}}} \right\}\). c)

\(L = \left\{ {\left. {{{\left( {000} \right)}^n}} \right|n \ge 0} \right\}\)

Then, \(G{\bf{ }} = {\bf{ }}\left( {V,{\bf{ }}T,{\bf{ }}S,{\bf{ }}P} \right)\) is a phrase structure grammar which generates the language L is \(V{\bf{ }} = {\bf{ }}\left\{ {0,{\bf{ }}S} \right\},{\bf{ }}T{\bf{ }} = {\bf{ }}\left\{ 0 \right\}\), S is the starting symbol and the productions are

Hence, the phase structure grammar for the set is \(S \to SS,S \to 000,S \to {\rm{\lambda }}\).

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

See all solutions

Recommended explanations on Math 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