$L = \{a^m b^n c^k \mid \text{ if $(n=k)$ then $(m=n)$}\}$ CFL or CSL?

402 Views Asked by At

Whether the given Language is CFL or CSL?

$L = \{a^m b^n c^k \mid \text{ if $(n=k)$ then $(m=n)$}\}$

I am getting as CSL. Professor teaching this course has provided explanation on basis of Propositional logic, stating if...then is equivalent to $((n≠k) \text{ or }m=n))$, on this ground, he claims to be CFL.

What I have understood is that we will take 2 cases Case 1: Check $n=k$, if yes then it will verify $m=n$, that will make Language $L$ as $a^n b^n c^n$ which will be CSL.

Case 2: If n≠k, then there is no restrictions on any parameters, it can be CFL. It can be accepted by empty stack or by final state.

Take Union of both cases, so the resulting language will be CSL (as CSL and CFL is closed under Union)

If you can provided state transition diagram for this language, that would be helpful. Correct me if I am wrong or misinterpreted some property of CFL?

1

There are 1 best solutions below

0
On BEST ANSWER

Following the explanation of your professor, one has \begin{align} L &= \{a^m b^n c^k \mid \text{if $(n=k)$ then $(m=n)$}\} \\ &= \{a^m b^n c^k \mid \text{$(n \not= k)$ or $(m=n)$}\} \\ &= \{a^m b^n c^k \mid m \geqslant 0 \text{ and } n \not= k\} \cup \{a^m b^n c^k \mid m=n \text{ and } k \geqslant 0\} \\ &= a^* \{b^n c^k \mid n \not= k\} \cup \{a^m b^n \mid m=n \}c^* \end{align} Now, the languages $\{b^n c^k \mid n \not= k\}$ and $\{a^m b^n \mid m=n \}$ are context-free. Furthermore, the product of a regular language and a context-free language is context-free and the union of two context-free languages is context-free. It follows that $L$ is context free.