Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
问题是提供上下文无关的语法,其中 L={w∈{a,b}∗∣w 中 a 的数量比 b 的数量大一}。我的解决方案是
S -> LaL L -> aLb|abL|bLa|Lab|Lba|baL|_
谁能告诉我为什么我的解决方案不适用于这种语言?
试试这个.. 可能会有更好/更简单的答案,但这通过了验证者的测试。
S -> A A -> BaAbB | BAabB | BabAB | BbaAB | BbAaB | a B -> bBa | aBb | _