1

I have a language $ L= \{ w \in \{a,b\}^* ; |w|_b=2i, i \ge 0 \}$ that is a language with even number of b's.

I found a grammar for it with these rules:

$S \rightarrow aS \ | \ bL \ | \ \lambda $

$L \rightarrow aL \ | \ bS \ $

How could I show that this language cannot be generated by linear grammar?

According to Wikipedia, a linear grammar is a context-free grammar that has at most one nonterminal in the right hand side of its productions.

Raphael
  • 72,336
  • 29
  • 179
  • 389
Martin
  • 111
  • 2

2 Answers2

2

Your grammar is right-regular and can thus be used to prove that $L \in \mathrm{REG}$. Since every regular grammar is linear, your claim is impossible to prove.

Raphael
  • 72,336
  • 29
  • 179
  • 389
1

A grammar whose only rules are of the form $X \to uYv$ and $X \to w$, where $u,v,w$ are terminals, can only generate words of odd length. Your language also contains words of even length. If you also allow rules of the form $X \to \epsilon$, then you can construct a grammar for your language (exercise).

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503