简体   繁体   中英

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; then we have no b's left; so we can't sompare them with c's.So, i think it should NOT be CFL.

But below solution shows that it is CFL

节能灯解决方案

In the above given solution, is L2 CFL correct ?

The language 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 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.

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.

Suppose a string w is in our language L. Then either m = n or not. If m = n, then 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. 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. So any string in L is in L2.

Suppose a string w is in L2. Then either m = n is false, or n = k is true. Suppose m = n is false. Then the condition if (m = n) then (n = k) is vacuously true (since the hypothesis is false, and everything follows from a contradiction). If n = k is true, then regardless of the truth value of the hypothesis, the implication if (hypothesis) then (n = k) must be true. So any string in L2 is in L.

Because L and L2 are subsets of each other, they must be equal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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