简体   繁体   中英

Context free grammar for L{a^n b^m c^t where t>0,m>0,n>2}

For a context free grammar for L{a^nb^mc^t where t>0,m>0,n>2}

S -> ABC
A ->aB|a
B ->bB|b
C ->cC|c

Is this correct?

This is incorrect. Your current grammar would allow the solution abc which is not part of your grammar since a does not appear more than two times.

It can be constructed the following way:
S -> ABC -> aBC -> abC -> abc

I would suggest the following grammar:

S -> aaABC
A -> aA|a
B -> bB|b
C -> cC|c

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM