简体   繁体   English

对语言和CFG的一些限制

[英]Some constraint on Language and CFG

I see one note about automaton theory: 我看到了有关自动机理论的一个注释:

Consider the following language: 考虑以下语言:

L={xy : x,y in {a,b}*} L = {xy:{a,b} *}中的x,y

and consider following constraint: 并考虑以下约束:

1) x=y 1)x = y

2) x != y 2)x!= y

3) x=(y)reverse 3)x =(y)反向

4) number of x is not equal to number of y 4)x的数量不等于y的数量

i read a language with constraint 2,3,4 is context free. 我阅读的语言有约束条件2,3,4是无上下文限制的。 any hint or tutorial for 1 to 3 is highly appreciated. 1至3的任何提示或教程均受到高度赞赏。

As you say, L 1 : {xy | x,y ∈ {a,b} * ∧ x=y} 如您所说, L 1 : {xy | x,y ∈ {a,b} * ∧ x=y} L 1 : {xy | x,y ∈ {a,b} * ∧ x=y} is not a context-free language. L 1 : {xy | x,y ∈ {a,b} * ∧ x=y}不是上下文无关的语言。

However, the very similar L 3 : {xy | x,y ∈ {a,b} * ∧ x=y -1 } 但是,非常相似的L 3 : {xy | x,y ∈ {a,b} * ∧ x=y -1 } L 3 : {xy | x,y ∈ {a,b} * ∧ x=y -1 } is context free, as follows: L 3 : {xy | x,y ∈ {a,b} * ∧ x=y -1 }是上下文无关的,如下所示:

S → Ø
S → a S a
S → b S b

Technically speaking, the two other languages in your question are trivial: 从技术上讲,您问题中的其他两种语言是微不足道的:

L 2 : {xy | x,y ∈ {a,b} * ∧ x≠y}
L 4 : {xy | x,y ∈ {a,b} * ∧ |x|≠|y|}

because the only string which does not satisfy the constraint is the empty string. 因为唯一不满足约束的字符串是空字符串。 Any non-empty string S can be trivially decomposed into the two non-equal strings Ø and S ; 可以将任何非空字符串S分解为两个非相等字符串ØS it's clear that the concatenation of these two strings is S and that unless S is empty, the two strings are unequal and have different lengths. 很明显,这两个字符串的串联是S ,除非S为空,否则这两个字符串是不相等的,并且具有不同的长度。 The language consisting of all non-empty strings is not only context free, but also regular: (a|b) + . 由所有非空字符串组成的语言不仅上下文无关,而且是常规的(a|b) +

Since that was so easy, I suspect that it is not what you were actually asking, but I cannot guess what you really meant. 由于这很容易,我怀疑这不是您真正要问的,但我无法猜测您的真正意思。 I suggest you edit the question to be more precise. 我建议您更精确地编辑问题。

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

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