简体   繁体   English

为什么此语法不上下文相关?

[英]Why is this Grammar not context sensitive?

I have got this grammar: 我有这个语法:

G = (N, Epsilon, P, S) G =(N,Epsilon,P,S)

with

N = {S, A, B}

Epsilon = {a},

P:    S -> e

      S -> ABA

      AB -> aa

      aA -> aaaA

      A -> a

Why is this a grammar of only type 0? 为什么这是仅类型0的语法?

I think it is because of aA -> aaaA , but I don't see how it is in conflict with the rules. 我认为这是因为aA -> aaaA ,但是我看不出它与规则有何冲突。

The rules have to be built like this: 规则必须像这样构建:

x1 A x2 -> x1 B x2 while: x1 A x2 -> x1 B x2而:

A is element of N; A是N的元素;

x1,x2 are elements of V*; x1,x2是V *的元素;

and B is element of VV*; B是VV *的元素;

With V = N united Epsilon , I don't see the problem here. 对于V = N united Epsilon ,我在这里看不到问题。

a is from V, and A is from N, while right of A there could be the empty word, which would also be part of V*, so the left side would be okay. a来自V,A来自N,而A的右边可能是空字,它也是V *的一部分,因此左侧可以。

On the right side, there is x1 again, being a, then we could say aaA is part of VV*, with aa being V and A being V*, while the right part is x2, so empty again. 在右侧,再次有x1,是a,那么我们可以说aaA是VV *的一部分,aa是V,A是V *,而右侧是x2,因此又是空的。

"The rules have to be built like this: x1 A x2 -> x1 B x2 while:...." yes, it's correct. “规则必须这样构建:x1 A x2-> x1 B x2 while:....”是的,这是正确的。 But, exists an equivalent definition of the rules (of type-1 grammars): p->q where p,q is element of V^+ and length(p)<=length(q) and -naturally- p has an element of N. Your grammar has only rules, that satisfy this form => your grammar is type-1 但是,存在规则的等效定义(类型1语法):p-> q,其中p,q是V ^ +的元素,而length(p)<= length(q)和-自然地-p有一个元素N。您的语法只有规则,且满足以下形式=>您的语法为1类

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

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