0

I need to prove whether the language $ L = \{w \in \{0,1\}^* \mid |w|_0 = |w|_1 \}$ can be written as a regular grammar. Obviously it can, but how do I prove it?

Yuval Filmus
  • 280,205
  • 27
  • 317
  • 514
Arat
  • 1

2 Answers2

0

A language can be described by a regular grammar if and only if it is regular. Your language is nor regular, hence it cannot be described as a regular grammar.

Yuval Filmus
  • 280,205
  • 27
  • 317
  • 514
0

That's not a formal proof, but some intuition that can be used sometimes to distinguish between regular & no-regular languages :

The constraint is : number of 0s equals number of 1s. Since we can have any number of 0s, and if we want to assign a state that tells how much 0s we have generated, we would have an infinite number of states. Thus, we can't use states to guide us, we need something like a memory to remember how much 0s we have at a certain instant. Knowing that regular languages are those that are recognized by FA's, in addition with the fact that FA's don't have memory, it's impossible to build a finite automaton to recognize that language. We can conclude prematurely that the language isn't regular.