/*! 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} Q26P Show that if G is a CFG in Choms... [FREE SOLUTION] | 91Ó°ÊÓ

91Ó°ÊÓ

Show that if G is a CFG in Chomsky normal form, then for any stringw∈L(G) of lengthn⩾1, exactly2n-1 steps are required for any derivation of w.

Short Answer

Expert verified

The given statement a given grammar Gis a context-free grammar in Chomsky normal form, then for any stringw∈LGof length n⩾1, exactly 2n-1steps are required for any derivation ofwis proved.

Step by step solution

01

Define Chomsky normal form

A context-free grammarG, is said to be in Chomsky normal formif all of its production rules are of the form

A→BC,orA→a,

02

Explain and prove given statement

First note that in rules of the form A→BC, neither Bnor Ccan beS

This means that in a derivation of a string w of length greater than zero, the ruleS→ε,

if it exists inGcannot be used, so the derivation can use only rules of the forms,

A→BC,orA→a,

Each application of a rule of the first form lengthens the string derived by one symbol.

Since the A→rules leave the length of the string the same, this means that A→BCrules are used exactly n-1times in deriving a string w of length n.

Since each use of a rule A→an introduces one terminal and this terminal can never be removed, rules of the formA→aare used exactly n times in the derivation of string w consisting of n terminals. In total, the derivation of w has length

n-1+n=2n-1.

The first step is that ifAis a variable ofGdifferent from S, then it is impossible to derive ε from A.

Here show the following more general statement: if Ais a variable and w is a string of terminals of length n⩾1, then any derivation of w from Ain Gtakes 2n-1steps.

The proof is by induction on n. If n=1, then w is a single terminal. If the derivation of w from A began with the rule A→BC, then, since neitherBnorCisSandA→awould have length at least two.

Thus, the derivation must consist of a single application of the ruleA→cand so has length one.

Since, 2×1-1=1, the desired relationship holds in this case.

Now, suppose that n>1and the result holds for strings of length jwith 1⩽j⩽n-1.

If w is a string of terminals of length n that can be derived from A, then the derivation must begin with a rule A→BC.

Let x=yz, where yis the part of xderived from Band zis the part derived from C. Since neither Bnor Cis Sneither ynor zis ε.

Thus, apply the inductive hypothesis to bothy and z. This means that if

y=kandz=n-k,

Then the derivation of y from Btakes2k-1 steps and the derivation of zfrom Ctakes2n-k-1 steps.

The total length of the derivation of w fromA is then

1+2k-1+2n-k-1=2n-1

which completes the induction.

Hence, it isproved that ifG is a context-free grammar in Chomsky normal form, then for any string w∈LGof lengthn⩾1,exactly2n-1steps are required for any derivation of w.

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.