Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Which one of the following languages is CFL and what is the grammar for it? Can we use pumping lemma for the not CFL?

\begin{align*} L_1 &= \{a^mb^ma^n \mid m,n \geq 0\}\\ L_2 &= \{a^mb^ma^n \mid m \geq n \geq 0\} \end{align*}

share|improve this question
    
Welcome to math.SE: since you are new, I wanted to let you know a few things about the site. In order to get the best possible answers, it is helpful if you say in what context you encountered the problem, and what your thoughts on it are; this will prevent people from telling you things you already know, and help them give their answers at the right level. If this is homework, please add the homework tag; people will still help, so don't worry. Also, many find rude writing a question that looks like it consists only of a verbatim quote; please consider rewriting your post. –  A.P. Apr 26 '13 at 12:07
    
Thank you very much for your comment. I will try to follow your guidance next time. –  Jesun Apr 26 '13 at 13:11

1 Answer 1

It’s very easy to write a context-free grammar that generates $L_1$. You might start with a production $S\to PA$ and add productions ensuring that $P$ generates $\{a^nb^n:n\ge 0\}$ and $A$ generates $a^*$.

Yes, you can use the pumping lemma for context-free languages to show that $L_2$ is not context-free; the proof is very similar to the usual example of such a proof, the proof that $\{a^nb^nc^n:n\ge 0\}$ is not context-free.

share|improve this answer
    
Thank you Brian for your hints. –  Jesun Apr 26 '13 at 13:12
    
@user1176123: You’re welcome; if you get completely stuck, feel free to ask me to expand the hints. –  Brian M. Scott Apr 26 '13 at 13:14
    
@ Brian M. Scott: for $L_2$, I am assuming a string $s = a^p b^p a^p$ , where p is the pumping length. Then I am arguing that s can be composed of xuyvw. Now 2 cases: 1. u and v may only contain one symbol: not both prefix a's and b's or b's and suffix a's. Then $xu^2yv^2z$ either violates $a^m b^m$ or no of b becomes less than no of a. Is the argument correct? For case 2: is it violating the order? Thanks in advance. –  Jesun Apr 27 '13 at 2:38
    
@user1176123: Yes, that’s correct: if $uyv$ contains both symbols, then $xu^2yv^2z$ contains two separate blocks of $b$’s. If $uyv$ is contained in the first $a$ block or the $b$ block, then $xu^2yv^2z$ doesn’t have the same number of $a$’s in its first block as it has $b$’s, and if it’s contained in the second $a$ block, then $xu^2yv^2z$ has too long a second $a$ block. –  Brian M. Scott Apr 27 '13 at 2:47
    
@ Brian M. Scott: Thank you very much for your help –  Jesun Apr 27 '13 at 3:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.