Example:Cardinality of evens

From CS2800 wiki

You might expect that the set of even natural numbers is smaller than the set of all natural numbers. But in fact, funny things happen with infinite sets:

Let [math]X := \href{/cs2800/wiki/index.php/Set_comprehension}{\{2n} \href{/cs2800/wiki/index.php/%5Cmid}{\mid} n \href{/cs2800/wiki/index.php/%E2%88%88}{∈} \href{/cs2800/wiki/index.php/%E2%84%95}{ℕ}\} [/math] be the set of even natural numbers. Then [math]│X│ \href{/cs2800/wiki/index.php/Equality_(cardinality)}{=} │ℕ│ [/math].
Proof: cardinality of evens
Let [math]f : X \href{/cs2800/wiki/index.php/%E2%86%92}{→} \href{/cs2800/wiki/index.php/%E2%84%95}{ℕ} [/math] be given by [math]f(2n) := n [/math]. [math]f [/math] is clearly a well-defined function, because every element of the domain is of the form [math]2n [/math] for exactly one [math]n [/math]. It is also clearly a bijection (details left as an exercise). Thus the evens and the naturals have the same cardinality.