Develop context-free grammars that generate languages:
L1 = {w|w is palindrome in {a,b}^* , w=w^*}
L2 = {ww^* | w is word of {a,b}^*}
My attempt
1)
S -> aSa | bSb | E | a | b
E is empty
Correct ?
2) I could not. Any tips?
Context-free grammar
Page 1 of 16 Replies - 6124 Views - Last Post: 02 July 2010 - 10:39 AM
Replies To: Context-free grammar
#2
Re: Context-free grammar
Posted 30 June 2010 - 11:41 AM
the first grammar is correct
the second language, i don't really think its a context free language, I think its in the next level of the hierarchy, needs a Turing machine to be able to recognize it, or maybe you just didn't write it correctly, i could be wrong though.
the second language, i don't really think its a context free language, I think its in the next level of the hierarchy, needs a Turing machine to be able to recognize it, or maybe you just didn't write it correctly, i could be wrong though.
#3
Re: Context-free grammar
Posted 30 June 2010 - 11:55 AM
actually i am pretty sure that the language ww^* is not context free. you can't design a CFG or a pda that would regonize a string that is concatenated to itself.
#4
Re: Context-free grammar
Posted 01 July 2010 - 09:54 AM
Doesn't w^* mean w repeated any number of times (even zero times)? Thus isn't ww^* just all non-empty strings over {a,b}^*?
#5 Guest_Garr*
Re: Context-free grammar
Posted 01 July 2010 - 01:38 PM
Mojo666, that is correct.
Mostyfriedman, you probably looked at Sipser and saw his example of "ww" not being context-free. True, but "ww*" is different. So, as Mojo pointed out, it's trivial to show that:
L2 = {ww^* | w is word of {a,b}^*} = {v | v is a word of {a,b}^*}
Obviously it's context-free.
Mostyfriedman, you probably looked at Sipser and saw his example of "ww" not being context-free. True, but "ww*" is different. So, as Mojo pointed out, it's trivial to show that:
L2 = {ww^* | w is word of {a,b}^*} = {v | v is a word of {a,b}^*}
Obviously it's context-free.
#6 Guest_Garr*
Re: Context-free grammar
Posted 01 July 2010 - 01:54 PM
Just a small correction. Mojo666, empty strings, should be fine too.
#7
Re: Context-free grammar
Posted 02 July 2010 - 10:39 AM
actually you guys are correct. it is context free.
Page 1 of 1

New Topic/Question
Reply



MultiQuote



|