in Theory of Computation
1,560 views
1 vote
1 vote
E -> E+T

E -> T

T -> (E)

T -> i
in Theory of Computation
by
1.6k views

1 comment

is there a way to do such questions?
0
0

1 Answer

4 votes
4 votes
Best answer

E -> ET’ / i
T’ -> PT
P -> +
E -> RE’
R -> (
E’ -> ES
S -> ) 
T -> RE’
T -> i

Here the key point is E->T so don't take it T epsilon. Simply take E-->(E) hence we can solve this.

Total {E,T',P,R,E'S,T} 7 variables.

edited by

9 Comments

edited by

hii @Ashwin

construction to CNF should never loss any strings, in your case atleast '( i )' and 'i' are lost

first remove unit production from above grammer you will get new grammer as,

E->E+T / (E) / i

T->(E)

T->i

now convert above grammer to CNF, you will get,

E->E'T / SR / i

T->SR / i

S->PE

E'->EM

P->(

R->)

M->+

total 7 non terminals and 4 terminals

0
0

Then why we cannot add

E--> i directly??

This will give exact result.

1
1

yes, i have added E--> i directly.

0
0
@joshi_nitish Hello, I'm saying in my result by adding E --> i, everything will be correct.

And production for P is missing in your CNF form.

And something is redundant as well . please can you check your CNF deduction again?
1
1
yes, something was redundant. thankyou.
0
0
i have already added E->i in your grammer. you readded it, now i removed it. :P
0
0
Hi thanks for ur analysis.

So if a cfg is to be converted to cnf, We should remove null production and unit productions.  As they will be a problem while converting.

Is it true?
0
0
Yes @gari. and CNF grammar should not contain null productions.

@joshi_nitish Infact I didn't know you can edit our answers :p haha.
1
1
Thanks @Ashwin :)
0
0

Related questions