Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

%3Cp%3E%3Cimg%20class%3D%22user-upload%22%20src%3D%0A%22http%3A%2F%2Fmedia.chegg

ID: 3551134 • Letter: #

Question

%3Cp%3E%3Cimg%20class%3D%22user-upload%22%20src%3D%0A%22http%3A%2F%2Fmedia.cheggcdn.com%2Fmedia%252F970%252F970d9a32-f860-494a-a070-7b7a5bfbc3a7%252FphpYZD1zo.png%22%0Aheight%3D%2295%22%20width%3D%22780%22%20%2F%3E%3C%2Fp%3E%0A%3Cp%3E%3Cbr%20%2F%3E%3C%2Fp%3E%0A%3Cp%3E%3Cspan%20class%3D%22c1%22%3EPlus%3C%2Fspan%3E%2C%3C%2Fp%3E%0A%3Cp%3E%3Cbr%20%2F%3E%3C%2Fp%3E%0A%3Cp%3E%3Cimg%20class%3D%22user-upload%22%20src%3D%0A%22http%3A%2F%2Fmedia.cheggcdn.com%2Fmedia%252F382%252F382ea89b-5412-4609-a13a-b46bab07780d%252Fphpq4ZXVn.png%22%0Aheight%3D%2245%22%20width%3D%22551%22%20%2F%3E%3C%2Fp%3E%0A

Explanation / Answer

L = {a^i b^j c^ k d^l }.

Language description: am bn consist of a followed by b where number of a are equal or more then number of b.

some example strings: {^, a, aa, aab, aabb, aaaab, ab......}

So there is always one a for one b but extra a are possible. infect string can be consist of a only. Also notice ^ null is a member of language because in ^ NumberOf(a) = NumberOf(b) = 0

How to write grammar for am bn?

In the grammar, there should be a rules such that if you add a b symbol you also add a a symbol.

anf this can be done with something like:

But this is incomplete because we need a rule to generate extra as for this rules are just below:

Combine two production rules into a single grammar CFG.

So you can generate any string consist of a also a and b in (am bn) pattern.

But in above grammar there is no way to generate ^ string.

So, Change this grammar like this:

this grammar can generate L = {a^i b^j c^ k d^l }.language.

Note: to generate ^ null string, I added an extra first step in grammar by adding S--> B | ^, So you can either add ^ or your string of symbol a and b. (now B plays role of S from previous grammar to generate equal numbers of a and b)


THE ABOVE GRAMMER IS AMBIGUOUS BECAUSE,

We were able to construct 2 distinct Derivations. Hence This Grammar is ambiguous.

"If a grammar produces at least 2 distinct parse tree or derivations, then the grammar is ambiguous."


I hope you get my answer. pls do rate :)