Why is this basic language not a regular language? L = {x in {0,1}* | x has an equal number of 0s &amp; 1s}

Based on the recursive definition of regular languages, isn't it possible to form a single regular language set over the binary alphabet {0,1} by doing the following?


concatenating 0's and 1's to form each of the binary strings satisfying the condition, resulting in a regular language consisting of that single string
union all the single-string regular languages together into one single regular language
Every language is the union of regular languages:
$$
L = \bigcup_{x \in L} \{ x \}.
$$
However, the set of regular languages is not closed under infinite unions. It isn't even closed under countably infinite unions, as your example demonstrates.

You can prove that your language is not regular in many ways. For example, if your language were regular, then so would its intersection with $0^*1^*$ be; yet this language is $\{ 0^n 1^n : n \geq 0 \}$, the classical example of a non-regular language. You can also prove non-regularity of your language directly, using either the pumping lemma or Myhill–Nerode theory.