Take the 2-minute tour ×
Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. It's 100% free, no registration required.

Identify the language given by $L = \{ x \in (0,1)^* : x \neq ww^R, w \in (0,1)^*\}$. Note: $w^R$ is the reverse of the string $w$.

Closure property can/should be applied only in the cases when the actual language is not specified. Otherwise, you may arrive at wrong conclusions. The language in question is fully specified, so I doubt whether one can directly apply closure property on $ww^R$, which you say, is its complement or vice versa. The given answer is CFL. But I don't seem to have arrived at it satisfactorily.

share|improve this question
4  
What kind of answer are you looking for? The language given is the complement of the language of all even-length palindromes over $\{0, 1\}$. The complement over the universe $\{0, 1\}^*$ is the language of all odd-length words and even-length non-palindromes. If you want a CFG, first make one for odd-length words, then for non-palindromes, and take the union. –  Patrick87 Nov 27 '12 at 19:18
    
@Patrick87. thanks. u mean L is CFG only? am i right? –  user1771809 Nov 27 '12 at 19:26
3  
What are you asking for? The language $L$ is context-free, and so is its complement. However, you cannot apply closure properties, since CFL are not closed under complement. Do you need a proof that $L$ is context-free? –  A.Schulz Nov 27 '12 at 20:27
    
@user1771809 Yes, $L$ is context-free, so there is a CFG which generates it. –  Patrick87 Nov 27 '12 at 20:54
    
@A.Schulz yes i am looking for a proof. i get confused when i saw a complement of CFG as CFG itself. –  user1771809 Nov 28 '12 at 18:43
show 1 more comment

1 Answer 1

If you want to show that $L$ is context-free, you can proceed as follows:

Build a push-down automaton $P$ that accepts $L$. $P$ will read the input and put all the read characters on its stack. At some point it guesses (non-deterministically!) that half of the input has been read. Then it reads the remaining input and checks it a against its stack. If $P$ finds a mismatching character it accepts, if it does find not a mismatch, or the guess for the middle of the word was wrong, it rejects.

share|improve this answer
    
This is proof by complementation which doesn't work in case of CFLs. Kindly correct me if i am wrong –  user1771809 Dec 12 '12 at 17:41
    
No it is not using "complementation". The PDA I sketched accepts $L$ not $\bar L$. Maybe the non-determinism confuses you. The PDA accepts, if there exists at least one accepting run. So you can "guess", when half of the input has been read. If your guess was wrong you reject. But there is one correct guess, if $x\in L$. –  A.Schulz Dec 12 '12 at 17:49
    
ok. i got it now. thanks A.Schulz –  user1771809 Dec 13 '12 at 15:59
add comment

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.