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

Let \({\bf{G = }}\left( {{\bf{V, T, S, P}}} \right)\) be the context-free grammar with \({\bf{V = }}\left\{ {\left( {\bf{,}} \right){\bf{S,A,B}}} \right\}{\bf{, T = }}\left\{ {\left( {\bf{,}} \right)} \right\}\) starting symbol \({\bf{S}}\), and productions

Show that \({\bf{L}}\left( {\bf{G}} \right)\) is the set of all balanced strings of parentheses, defined in the preamble to Supplementary Exercise \(55\) in Chapter \(4\).

Short Answer

Expert verified

\({\bf{L}}\left( {\bf{G}} \right){\bf{ = }}\) It is the set of balanced strings of parentheses.

Step by step solution

Achieve better grades quicker with Premium

  • Unlimited AI interaction
  • Study offline
  • Say goodbye to ads
  • Export flashcards

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

01

Definition

In formal language theory, a context-free grammar is a formal grammar whose production rules are of the form\({\bf{A}}\)to\({\bf{\alpha }}\)with a single nonterminal symbol, and\({\bf{\alpha }}\)a string of terminals and/or non-terminals.

Given: \({\bf{B}}\) is the set of all balanced strings

\({\bf{\lambda }} \in {\bf{B}}\)

\({\bf{(x)}} \in {\bf{B}}\)if \({\bf{x}} \in {\bf{B}}\)

\({\bf{xy}} \in {\bf{B}}\)if \({\bf{xy}} \in {\bf{B}}\)

\(\begin{array}{l}{\bf{G = (V,T,S,P)}}\\{\bf{V = \{ (,),S,A,B\} }}\\{\bf{T}} = {\bf{\{ (,)\} }}\\{\bf{S}} \to {\bf{A}}\\{\bf{A}} \to {\bf{AB}}\\{\bf{A}} \to {\bf{B}}\\{\bf{B}} \to {\bf{(A)}}\\{\bf{B}} \to {\bf{()}}\\{\bf{S}} \to {\bf{\lambda }}\end{array}\)

02

Using the strong induction

To proof: \({\bf{L}}\left( {\bf{G}} \right){\bf{ = }}\) Set of all balanced strings of parentheses.

PROOF BY STRONG INDUCTION

Assume \({\bf{P(n)}}\) be the statement "String \({\bf{x}}\) which is produced by \({\bf{G}}\) is a balanced string when \({\bf{x}}\) is a balanced string with \({\bf{2n}}''\).

Base step \({\bf{n = 0}}\).

The only string of length \({\bf{2 n = 2}}\left( {\bf{0}} \right){\bf{ = 0}}\) is the empty string \({\bf{\lambda }}\).

Note that \({\bf{\lambda }}\) is generated by \({\bf{G}}\) due to the production rule \({\bf{S}} \to {\bf{\lambda }}\). Moreover, \({\bf{\lambda }}\) is also a balanced string as \({\bf{\lambda }} \in {\bf{B}}\). Thus \({\bf{P}}\left( {\bf{0}} \right)\) is true.

Inductive step Let \({\bf{P(0),P(1), \ldots ,P(k)}}\) be true, thus the string \({\bf{x}}\) that is produced by \({\bf{G}}\) is a balanced string when \({\bf{x}}\) is a balanced string with length \({\bf{2i}}\) for \({\bf{i = 0,1,2, \ldots ,k}}\).

03

Proving \({\bf{P}}\left( {{\bf{k + 1}}} \right)\) is true

Let \({\bf{y}}\) be a string of length \({\bf{2}}\left( {{\bf{k + 1}}} \right){\bf{ = 2 k + 2}}\) that is produced by \({\bf{G}}\).\({\bf{y}}\) is then of the form \(\left( {\bf{x}} \right)\) or of the form \({\bf{a b}}\) (with \({\bf{x}}\), \({\bf{a}}\) and \({\bf{b}}\) strings that were produced by \({\bf{G}}\)).

If \({\bf{y}}\) is of the form \(\left( {\bf{x}} \right)\), then \({\bf{x}}\) is a string of length \({\bf{2k}}\). Since \({\bf{P(k)}}\) is true, \({\bf{x}}\) is a balanced string \({\bf{x}} \in {\bf{B}}\). Since \({\bf{x}} \in {\bf{B}}\) : \({\bf{(x)}} \in {\bf{B}}\) and thus \({\bf{y = }}\left( {\bf{x}} \right)\) is a balanced string.

If \({\bf{y}}\) is of the form \({\bf{a b}}\), then \({\bf{a}}\) is a string of length \({\bf{2i}}\) while \({\bf{b}}\) is a string of length \({\bf{2 k + 2 - 2 i = 2}}\left( {{\bf{k + 1 - i}}} \right)\). Since \({\bf{P(i)}}\) is true, \({\bf{a}}\) is a balanced string \({\bf{a}} \in {\bf{B}}\). Since \({\bf{P}}\left( {{\bf{k + 1 - i}}} \right)\) is true, \({\bf{b}}\) is a balanced string \({\bf{b}} \in {\bf{B}}\). Since \({\bf{a}} \in {\bf{B}}\) and \({\bf{b}} \in {\bf{B}}\):\({\bf{ab}} \in {\bf{B}}\) and thus \({\bf{y = ab}}\) is a balanced string.

Thus \({\bf{P}}\left( {{\bf{k + 1}}} \right)\) is true.

Conclusion by the principle of strong induction, \({\bf{P(n)}}\) is true for all nonnegative integers \({\bf{n}}\).

Therefore, \({\bf{L}}\left( {\bf{G}} \right){\bf{ = }}\) Set of all balanced strings of parentheses.

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

Express each of these sets using a regular expression.

  1. The set containing all strings with zero, one, or two bits
  2. The set of strings of two 0s, followed by zero or more 1s, and ending with a 0
  3. The set of strings with every 1 followed by two 0s
  4. The set of strings ending in 00 and not containing 11
  5. The set of strings containing an even number of 1s

Give production rules in extended Backusโ€“Naur form that generate all decimal numerals consisting of an optional sign, a nonnegative integer, and a decimal fraction that is either the empty string or a decimal point followed by an optional positive integer optionally preceded by some number of zeros.

Let V = {S, A, B, a, b} and T = {a, b}. Determine whether G = (V, T, S, P) is a type 0 grammar but not a type 1 grammar, a type 1 grammar but not a type 2 grammar, or a type 2 grammar but not a type 3 grammar if P, the set of productions, is

\(\begin{array}{*{20}{l}}{{\bf{a) S }} \to {\bf{ aAB, A }} \to {\bf{ Bb, B }} \to {\bf{ \lambda }}{\bf{.}}}\\{{\bf{b) S }} \to {\bf{ aA, A }} \to {\bf{ a, A }} \to {\bf{ b}}{\bf{.}}}\\{{\bf{c) S }} \to {\bf{ABa, AB }} \to {\bf{ a}}{\bf{.}}}\\{{\bf{d) S }} \to {\bf{ ABA, A }} \to {\bf{ aB, B }} \to {\bf{ ab}}{\bf{.}}}\\{{\bf{e) S }} \to {\bf{ bA, A }} \to {\bf{ B, B }} \to {\bf{ a}}{\bf{.}}}\\{{\bf{f ) S }} \to {\bf{ aA, aA }} \to {\bf{ B, B }} \to {\bf{ aA, A }} \to {\bf{ b}}{\bf{.}}}\\{{\bf{g) S }} \to {\bf{ bA, A }} \to {\bf{ b, S }} \to {\bf{ \lambda }}{\bf{.}}}\\{{\bf{h) S }} \to {\bf{ AB, B }} \to {\bf{ aAb, aAb }} \to {\bf{ b}}{\bf{.}}}\\{{\bf{i) S }} \to {\bf{ aA, A }} \to {\bf{ bB, B }} \to {\bf{ b, B }} \to {\bf{ \lambda }}{\bf{.}}}\\{{\bf{j) S }} \to {\bf{ A, A }} \to {\bf{ B, B }} \to {\bf{ \lambda }}{\bf{.}}}\end{array}\)

In Exercises 16โ€“22 find the language recognized by the given deterministic finite-state automaton

Find the output generated from the input string 10001 for the finite-state machine with the state diagram in

a) Exercise 2(a).

b) Exercise 2(b).

c) Exercise 2(c).

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