Reputation: 539
I heard that a*b*c* is not regular. At the same time, i got the following regular grammar to generate it as well.
S → A
A → aA
A → B
B → bB
B → C
C → cC
C-> empty
Can anyone clarify is this grammar correct to generate a*b*c*
Thanks
Upvotes: 0
Views: 2544
Reputation: 280227
a*b*c*
is a perfectly regular language. In fact, the presentation is itself a proof that the language is regular; it's a regular expression in the classical sense.
The language you're probably thinking of is (a^n)(b^n)(c^n)
, or, since code formatting is a horrible substitute for TeX typesetting, the language of strings consisting of n a's, n b's, and n c's for all n. The important difference is that there must be the same number of a's, b's, and c's.
Upvotes: 2