Context-sensitive Grammar for a^nb^nc^n

2.6k views Asked by At

Is the following CSG for a^nb^nc^n correct?

S->aSbC|abc
Cb->bC
C->c

If not please explain why?

1

There are 1 answers

1
Parth Sarathi Pathak On

Productions:
S -> abc | aAbc
Ab -> bA
Ac -> Bbcc
bB -> Bb
aB -> aa | aaA

Solution:

S → aAbc
→ abAc
→ abBbcc
→ aBbbcc
→ aaAbbcc
→ aabAbcc
→ aabbAcc
→ aabbBbccc
→ aabBbbccc
→ aaBbbbccc
→ aaabbbccc