简化后此文法的乔姆斯基分类是什么?我还是很困惑

what is the Chomsky classification of this grammar after reduction ? i'm still confused

这是还原前的语法:

我的减少步骤是

1-代

S -> aC

A -> bSca

C -> 广告

2- 可达

S -> aC

C -> 广告

我仍然对这个语法的乔姆斯基分类感到困惑

Wikipedia article on the Chomsky hierarchy 提供了简单的定义。特别是,它表示 Type 2(上下文无关)语法是:

defined by rules of the form A → α with A being a nonterminal and α being a string of terminals and/or nonterminals.

还有一个 Type 3(常规)语法:

restricts its rules to a single nonterminal on the left-hand side and a right-hand side consisting of a single terminal, possibly followed by a single nonterminal.

你的最终语法是:

S → aC
C → ad

严格来说,这不是 Type 3 文法,因为 C 的产生式不是 "single terminal possibly followed by a single non-terminal";相反,它是一个终端,后面跟着另一个终端。但这可以简单地重写为

S → aC
C → aD
D → d

其中所有产生式都遵守类型 3 限制。这种简单的转换可以应用于任何语法,其产生式由一个或多个终结符组成,可能后跟一个非终结符,并且通常用作定义而不是维基百科中的定义,因为最终结果实际上是相同的.

我们可以看出,每一个Type 3文法也是Type 2文法,因为Type 3文法允许的右手边也符合描述"a string of terminals and/or nonterminals"。所以说你最终的文法是Type 2也没有错,但是因为它也是Type 3,所以我们通常会把它描述成Type 3文法。