Re: Is this language context free?
- From: Chris Smith <cdsmith@xxxxxxxxx>
- Date: 14 Jul 2008 06:06:43 GMT
Dillon wrote:
The language L = {xyz | x = y^R, z is a string with only c's, and x !=
z} Here y^R denotes the string obtained by reversing y.
Yes, it is context-free. It turns out this is the same as L' =
{ xyz | x = y^R, z contains only c's }. Here's why they are the same
language.
First, that w in L implies w in L' is obvious, since L is a subset of L'
by adding the additional condition. So the remaining task is to show
that if w is in L', then w is also in L.
There are two cases. In case #1, the input string does not contain all
'c' characters. Then if w is in L', then take the division into w = xyz
that must exist because w is in L'. Observe that x must contain a
non-'c' character; otherwise, there would be all 'c' characters in w. So
clearly x != z, so w = xyz satisfies all the conditions of L. Therefore,
w is in L. In case #2, w consists of all 'c' characters. Then let x and
y both be the empty string, and z = w. Then w = xyz, and all the
conditions of L are satisfied.
(I interpreted "contains only c's" to mean that z must contain at least
one 'c'. If you allow z to be empty, then the two languages will differ
on the empty string.)
So since L = L', the context-free grammar for L, which is trivial to
write down, also suffices for L'.
--
Chris Smith
.
- References:
- Is this language context free?
- From: Dillon
- Re: Is this language context free?
- From: Chris Smith
- Re: Is this language context free?
- From: Dillon
- Is this language context free?
- Prev by Date: Does the size of the stack of a PDA matter?
- Next by Date: Re: Rice's theorem
- Previous by thread: Re: Is this language context free?
- Next by thread: TAUTOLOGY and SAT
- Index(es):
Relevant Pages
|