Question

Provide  context-free grammars for the following languages : (a) {(a^n)(b^m) | n ≥ (2^m)}. (b) {(a^i)(b^j)(c^k)(d^l)| i...

Provide  context-free grammars for the following languages :

(a) {(a^n)(b^m) | n ≥ (2^m)}.

(b) {(a^i)(b^j)(c^k)(d^l)| i + j = k + l}.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

(a). {(a^n)(b^m) | n ≥ (2^m)}

S -> aaSb | aS | λ

(b) If this solution seems strange, it may seem less so if you tackle this problem first. We introduce two non-terminals, L1 and L2 - the first will produce all legal strings with more a's than d's, and the second will produce more d's than a's. For the first we give the production rules

L1→aL1d

L1→M1

M1→aM1c

M1→N1

N1→bN1c

Similarly,

L2→aL2d

L2→M2

M2→bM2d

M2→N2

N2→bN2c

Clearly distinguishing between N1 and N2 is unnecessary, but I think it makes the presentation more readable. Finally, to formally put this into a proper CFG we add in

S→L1

S→L2

N1→ε

N2→ε

where S is the start symbol, and εε is the empty string

Add a comment
Know the answer?
Add Answer to:
Provide  context-free grammars for the following languages : (a) {(a^n)(b^m) | n ≥ (2^m)}. (b) {(a^i)(b^j)(c^k)(d^l)| i...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT