开发者

Chomsky Normal Form correctness

开发者 https://www.devze.com 2023-03-18 12:29 出处:网络
I have these productions: S->aSb S-> eps(eps=empty string) I should apply the Chomsky Normal Form My reasoning:

I have these productions:

S->aSb
S-> eps      (eps=empty string)

I should apply the Chomsky Normal Form

My reasoning:

1) eliminate the eps rules Given:

S->aSb
S-> eps

I get:

S->ab

S->aSb

2) eliminate the unit rules

Th开发者_高级运维ere are none

3) remove useless symbols

I get:

S->ab

So, the given grammar after applying CNF (Chomsky Normal Form) becomes:

S->ab

Am I right?


What you have here is not quite the same. Notice that the empty string is no longer part of your language, nor are the strings aabb, aaabbb, etc.

Chec the step where you eliminate useless rules. Is that second rule really useless?

Also, are you sure you can eliminate the epsilon production?

0

精彩评论

暂无评论...
验证码 换一张
取 消