简体   繁体   English

是 L = {a^mb^nc^k | if (m=n) then (n=k) } CFL 与否?

[英]Is L = {a^mb^nc^k | if (m=n) then (n=k) } CFL or not?

I see that in this language , by the time we are deciding m=n;我看到在这种语言中,当我们决定 m=n 时; then we have no b's left;那么我们就没有b了; so we can't sompare them with c's.So, i think it should NOT be CFL.所以我们不能用c's.Sompare它们。所以,我认为它不应该是CFL。

But below solution shows that it is CFL但下面的解决方案表明它是 CFL

节能灯解决方案

In the above given solution, is L2 CFL correct ?在上面给出的解决方案中,L2 CFL 是否正确?

The language L = {a^mb^nc^k |语言 L = {a^mb^nc^k | if (m = n) then (n = k)} is a context-free language for exactly the reason given in the second derivation: the condition if (m = n) then (n = k) is not only true when m = n and n = k, but also when m is not equal to n. if (m = n) then (n = k)} 是一种上下文无关语言,正是因为第二个推导中给出的原因:条件 if (m = n) then (n = k) 不仅在 m = 时为真n 和 n = k,而且当 m 不等于 n 时。 If the condition were (m = n) and (n = k) the language would not be context free since this condition would be equivalent to m = n = k.如果条件是 (m = n) 和 (n = k),则该语言将不是上下文无关的,因为此条件等效于 m = n = k。

We can prove the derivation which shows the language to be context-free correct by showing anything in L is in L2, and vice versa.我们可以通过显示 L 中的任何内容在 L2 中来证明该语言是上下文无关的正确推导,反之亦然。

Suppose a string w is in our language L. Then either m = n or not.假设字符串 w 在我们的语言 L 中。那么要么 m = n,要么不。 If m = n, then n = k.如果 m = n,则 n = k。 But then the string w is in L2 since L2 is the union of two languages, one of which contains all strings with n = k.但是字符串 w 在 L2 中,因为 L2 是两种语言的并集,其中一种包含 n = k 的所有字符串。 If m = n is not the case, then the string w is in L2 because L2 is the union of two languages, the other of which is the language of all strings where m and n are not equal.如果 m = n 不是这种情况,则字符串 w 在 L2 中,因为 L2 是两种语言的并集,其中另一种是 m 和 n 不相等的所有字符串的语言。 So any string in L is in L2.所以 L 中的任何字符串都在 L2 中。

Suppose a string w is in L2.假设字符串 w 在 L2 中。 Then either m = n is false, or n = k is true.那么要么 m = n 为假,要么 n = k 为真。 Suppose m = n is false.假设 m = n 为假。 Then the condition if (m = n) then (n = k) is vacuously true (since the hypothesis is false, and everything follows from a contradiction).那么条件 if (m = n) then (n = k) 是空洞的(因为假设是错误的,一切都来自矛盾)。 If n = k is true, then regardless of the truth value of the hypothesis, the implication if (hypothesis) then (n = k) must be true.如果 n = k 为真,那么无论假设的真值如何,蕴涵 if (hypothesis) then (n = k) 必须为真。 So any string in L2 is in L.所以 L2 中的任何字符串都在 L 中。

Because L and L2 are subsets of each other, they must be equal.因为 L 和 L2 是彼此的子集,所以它们必须相等。

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

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