I have a homework assignment that requires me to create CFG $G$ for
$$L = \{a^i b^{i+j+k} c^j d^k\}$$
so that it can accept words like ab, aaabbbbd, abbbcd, but it should not accept abba, aabbbbbc, or abc since the number of b must be the number of a+c+d.
I need CFG of L(G)
- I tried using chatgpt but the answers are not correct as I cross checked them with both gpt and myself.
- I tried to cross check this pdf but they are not as complex as my question.
- There is also a solution on chegg I can't see the whole solution as I don't have a subscription, but the final solution is also wrong as I checked it with both chatgpt and myself.
- Also researched multiple sources but did not found the answer.
The best one i came up with this grammer but it doesn't feel right since it does not have corelation between b c and d.
1. attempt:
S → AB
A → aAb | ε
B -> bCEdD
C -> bB | ε
D -> dD | ε
E -> bEc | ε
2. attempt :
S → AB
A → aA | ε
B → bBC
C → cC | Cd | ε
D → dD | ε
Is it possible to do it with cfg and how?