-1

Is $\left ( 0+1 \right )^{\ast }-\left \{ www : w \in \left \{ 0,1 \right \}^{\ast } \right \}$ context-free?

If it is what is a grammar generating it?

Raphael
  • 73,212
  • 30
  • 182
  • 400
Azar
  • 15
  • 1

2 Answers2

1

Here is an idea for you to elaborate on. [Edited after Hendrik's comment:] But maybe the idea does not work so well.

Call your language $L$ and consider $L'=L\cap 0^*10^*10^*10^*$. When does a word $w$ of the form $0^a10^b10^c10^d$ belong to $L'$? When $2a\not=b\lor b\not= c\lor c\not=2d$. It seems difficult for a pushdown automaton to read $w$, compare $2a$ with $b$ and then remember enough of $b$ to compare it with $c$. What should one conclude ?!

When trying to show that a language is not context-free, intersecting with a regular language is a reduction that often permits simpler ways of showing what is not context-free in the language at hand. Without such reductions using the pumping lemma can be unnecessarily painful.

phs
  • 871
  • 5
  • 7
0

What @Raphael says and the following diagram, with $a\neq b$.

But let me be more precise. A string is not of the form $www$ if either its length is not divisible by three or, when it is of length $3n$, then there are two positions exactly $n$ apart that have different letters. Hence the following diagram.

$\underbrace{\dots a}_k \; \underbrace{\dots\dots\dots b}_n\; \underbrace{\dots\dots\dots\dots\dots}_{2n-k}$

To get a language like this we have to do two things: get the lengths of the three segments right, and synchronize the $a\neq b$. As a first step towards a grammar I would consider the segment lengths, and study a related language: $K= \{ a^k b^n c^m \mid m+k=2n \}$. That is, for each $b$ write two $a$'s or two $c$'s, or if these numbers are odd, add one each.

Hendrik Jan
  • 31,459
  • 1
  • 54
  • 109