**Definition** The cardinality (number of elements) of \(S\) is at most that of \(T\), \(|S|\leq |T|\), iff there is a one-to-one mapping from \(S\) to \(T\) (or, equivalently, an onto/surjective mapping from \(T\) to \(S\)).

**Definition** \(|S|=|T|\) iff \(|S|\leq |T|\) and \(|T|\leq |S|\).

**Definition** The set \(S\) is countable iff \(|S|\leq |\mathbb{N}|\).

Ex.

- Even natural number
- \(\mathbb{N}=\{...,-3,-2,-1,0,1,2,3,...\}\)
- \(f(a)=2a\) if \(a>0\)
- \(f(a)=-2a+1\) if \(a\leq 0\)

- \(\mathbb{Q}^+=\{\frac{m}{n}:m,n\in\mathbb{N}\}\)
- \(f(m,n)=2^m2^n\)

- \(\mathbb{T}=\{M:M\) is a Turing Machine\(\}\)
- \(M=(Q,\Sigma,\Gamma,\delta,q_0,q_{acc},q_{rej})\)
- \(Q\rightarrow |Q|\), \(\Sigma\rightarrow |\Sigma|\), \(\Gamma\rightarrow |\Gamma|\)
- \(q_0, q_{acc}, q_{rej}\rightarrow\) number between \(1\) and \(|Q|\).
- \(\delta\rightarrow 2^{|Q|\times|\Gamma|\times|Q|\times|\Gamma|\times 2}\)

**Theorem** The set of all Turing Machines is countable.

**Proof** We can encode each Turing Machine into an ASCII string, write it in binary, take the mapping that associates \(M\) with the natural number whose binary representation is that encoding binary number (Uniqueness?!).

**Definition** The set \(S\) is uncountable if it is not countable.

\(S\) is uncountable iff it is impossible to map \(\mathbb{N}\) to \(S\) in a way that covers each element of \(S\).

**Theorem** The set \(\mathbb{L}\) of all languages over \(\Sigma=\{a,b\}\) is uncountable.

**Proof** By **diagonalization**.

Assume by contradiction that \(\mathbb{L}\) is countable, so there is a mapping \(\phi:\mathbb{N}\rightarrow\mathbb{L}\) such that every \(L\in\mathbb{L}\) equals \(\phi(n)\) for some \(n\in\mathbb{N}\)

Every \(L\) in \(\mathbb{L}\) can be represented as an infinite sequence \(s\) over \(\{0,1\}\) where the \(i^{th}\) element of \(s\) indicates wheter the \(i^{th}\) string over \(\{a,b\}\) is in \(L\) or not.

e.g. \(L=\{b,aa,bb\}=01101000...\)

Then \(\phi\) can be written out as

e.g.

\(n\) | \(\phi(n)\) |
---|---|

1 | 0000... |

2 | 1000... |

3 | 1110... |

4 | 0001... |

Consider the language \(L^*\) with corresponding sequence is obtained by flipping the \(i^{th}\) coordinate of the sequence of \(\phi(i)\).

By construction of \(\phi\), there must exist \(n^*\in\mathbb{N}\) such that \(\phi(n^*)=L^*\). Does \(L^*\) include \(n^*\)th string?