简体   繁体   English

L={ a^nb^m: n <= m+3, n,m>=0} 的 CFG

[英]CFG for L={ a^n b^m : n <= m+3 , n,m>=0}

I want to find Context Free Grammar for L={ a^nb^m: n <= m+3, n,m>=0}我想找到 L={ a^nb^m: n <= m+3, n,m>=0} 的上下文无关语法

What I have so far到目前为止我所拥有的

S -> AAAB
A -> a | ε
B -> aBb | Bb | ε

Does this make any sense?这有道理吗?

First of all this CFG should work properly But the CFG below is more readable:首先,这个 CFG 应该可以正常工作但下面的 CFG 更具可读性:

S -> aSb | A | B
A -> a | aa | aaa | ε
B -> bB | ε

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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