Use the below proof to give a context free grammar that accepts palin-dromes. A
ID: 3080707 • Letter: U
Question
Use the below proof to give a context free grammar that accepts palin-dromes.
Explanation / Answer
A "context-free language" is simply one that can be described with a context-free grammar. Period. Order matters in any language. "It even matters in English." is a valid sentence. "English in matters it even." is not. If English were context-free (it isn't) then a noun would always be a noun, no matter where it appears. The Groucho Marx line is one of my favorite illustrations: "Time flies like an arrow. Fruit flies like a banana." Same apparent form, but "flies" and "like" are different parts of speech in each sentence. As for the "equal number of a's and b's", I can't imagine a (finite) context-free grammar for that language. I don't think that even the simpler language of (repeat of the same ab pattern), as in {"aabbbaabbb", "abab", "bb", "aa", "baabaa", ...} is context-free. Palindromes, though, can be done easily: ::= ::= a a ::= b b ::= a a ::= b b As far as I know, there's no easy test to decide whether a particular language is NOT context-free. "I can't think of a context-free grammar." isn't a proof.Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.