==Definition==
The most concise definition is in terms of [[cardinality]]. A set <math>{{mvar|S</math>}} is ''countable'' if its cardinality <math>|S|</math> is less than or equal to <math>\aleph_0</math> ([[aleph-null]]), the cardinality of the set of [[natural numbers]] <math>\N = \{ 0, 1, 2, 3, \ldots \}</math>. A set <math>{{mvar|S</math>}} is ''countably [[infinite set|infinite]]'' if <math>|S| = \aleph_0</math>. A set is ''[[uncountable]]'' if it is not countable, i.e. its cardinality is greater than <math>\aleph_0</math>; the reader is referred to [[Uncountable set]] for further discussion.<ref>{{cite book |last1=Yaqub |first1=Aladdin M. |title=An Introduction to Metalogic |date=24 October 2014 |publisher=Broadview Press |isbn=978-1-4604-0244-3 |url=https://books.google.com/books?id=cyljCAAAQBAJ&pg=PT187 |language=en}}</ref>
For every set <math>{{mvar|S</math>}}, the following propositions are equivalent:
* <math>{{mvar|S</math>}} is countable.<ref name="Lang"/>
* There exists an [[injective function]] from {{mvar|S}} to <math>{{tmath|\N</math>}}.<ref name=Singh>{{cite book |last1=Singh |first1=Tej Bahadur |title=Introduction to Topology |date=17 May 2019 |publisher=Springer |isbn=978-981-13-6954-4 |page=422 |url=https://books.google.com/books?id=UQiZDwAAQBAJ&pg=PA422 |language=en}}</ref><ref name=Katzourakis>{{cite book |last1=Katzourakis |first1=Nikolaos |last2=Varvaruca |first2=Eugen |title=An Illustrative Introduction to Modern Analysis |date=2 January 2018 |publisher=CRC Press |isbn=978-1-351-76532-9 |url=https://books.google.com/books?id=jBFFDwAAQBAJ&pg=PT15 |language=en}}</ref>
* <math>{{mvar|S</math>}} is empty or there exists a [[surjective function]] from <math>{{tmath|\N</math>}} to <math>{{mvar|S</math>}}.<ref name=Katzourakis/>
* There exists a [[bijective]] mapping between <math>{{mvar|S</math>}} and a subset of <math>{{tmath|\N</math>}}.<ref>{{harvnb|Halmos|1960|loc=p. 91}}</ref>
* <math>{{mvar|S</math>}} is either [[Finite set|finite]] or countably infinite.<ref>{{Cite web|last=Weisstein|first=Eric W.|title=Countable Set |url=https://mathworld.wolfram.com/CountableSet.html|access-date=2020-09-06|website=mathworld.wolfram.com|language=en}}</ref>
Similarly, the following propositions are equivalent:
* <math>{{mvar|S</math>}} is countably infinite.
* There is an injective and surjective (and therefore [[bijection|bijective]]) mapping between <math>{{mvar|S</math>}} and <math>{{tmath|\N</math>}}.
* <math>{{mvar|S</math>}} has a [[One-one correspondence|one-to-one correspondence]] with <math>{{tmath|\N</math>}}.<ref>{{harvnb|Kamke|1950|loc=p. 2}}</ref>
* The elements of <math>{{mvar|S</math>}} can be arranged in an infinite sequence <math>a_0, a_1, a_2, \ldots</math>, where <math>a_i</math>{{mvar|a{{sub|i}}}} is distinct from <math>a_j</math>{{mvar|a{{sub|j}}}} for <{{math>|''i\neq'' ≠ ''j</math>''}} and every element of <math>{{mvar|S</math>}} is listed.<ref>{{cite book |last1=Dlab |first1=Vlastimil |last2=Williams |first2=Kenneth S. |title=Invitation To Algebra: A Resource Compendium For Teachers, Advanced Undergraduate Students And Graduate Students In Mathematics |date=9 June 2020 |publisher=World Scientific |isbn=978-981-12-1999-3 |page=8 |url=https://books.google.com/books?id=l9rrDwAAQBAJ&pg=PA8 |language=en}}</ref><ref>{{harvnb|Tao|2016|p=182}}</ref>
==History==
==Introduction==
A ''[[Set (mathematics)|set]]'' is a collection of ''elements'', and may be described in many ways. One way is simply to list all of its elements; for example, the set consisting of the integers 3, 4, and 5 may be denoted {{math|{3, 4, 5},}} called roster form.<ref>{{Cite web|date=2021-05-09|title=What Are Sets and Roster Form?|url=https://www.expii.com/t/what-are-sets-and-roster-form-4300| url-status=live|website=expii|archive-url=https://web.archive.org/web/20200918224155/https://www.expii.com/t/what-are-sets-and-roster-form-4300 |archive-date=2020-09-18 }}</ref> This is only effective for small sets, however; for larger sets, this would be time-consuming and error-prone. Instead of listing every single element, sometimes an ellipsis ("...") is used to represent many elements between the starting element and the end element in a set, if the writer believes that the reader can easily guess what ... represents; for example, {{math|{1, 2, 3, ...…, 100} }} presumably denotes the set of [[integer]]s from 1 to 100. Even in this case, however, it is still ''possible'' to list all the elements, because the number of elements in the set is finite. If we number the elements of the set {{nowrap|1, 2,}} and so on, up to <math>{{mvar|n</math>}}, this gives us the usual definition of "sets of size <math>{{mvar|n</math>}}".
[[File:Aplicación 2 inyectiva sobreyectiva02.svg|thumb|x100px|Bijective mapping from integer to even numbers]]
Some sets are ''infinite''; these sets have more than <math>{{mvar|n</math>}} elements where <math>{{mvar|n</math>}} is any integer that can be specified. (No matter how large the specified integer <math>{{mvar|n</math>}} is, such as <{{math>|1=''n'' = 10^{{sup|1000}</math>}}}, infinite sets have more than <math>{{mvar|n</math>}} elements.) For example, the set of natural numbers, denotable by {{math|{0, 1, 2, 3, 4, 5, ...…},}}{{efn|name=ZeroN|Since there is an obvious [[bijection]] between <math>{{tmath|\N</math>}} and <math>\N^*=\{1,2,3,\dots\},</math>, it makes no difference whether one considers 0 a natural number or not. In any case, this article follows [[ISO 31-11]] and the standard convention in [[mathematical logic]], which takes 0 as a natural number.}} has infinitely many elements, and we cannot use any natural number to give its size. It might seem natural to divide the sets into different classes: put all the sets containing one element together; all the sets containing two elements together; ...; finally, put together all infinite sets and consider them as having the same size. This view works well for countably infinite sets and was the prevailing assumption before Georg Cantor's work. For example, there are infinitely many odd integers, infinitely many even integers, and also infinitely many integers overall. We can consider all these sets to have the same "size" because we can arrange things such that, for every integer, there is a distinct even integer:
<math display="block">\ldots \,\ - \;\! 2\! 2 \rightarrow \! - \! 4, \, - \! 1\! \rightarrow \! - \! 2, \, 0\! \rightarrow \! 0, \, 1\! \rightarrow \! 2, \, 2\! \rightarrow \! 4, \, \cdotsldots</math>
or, more generally, <math>n \rightarrow 2n</math> (see picture). What we have done here is arrange the integers and the even integers into a ''one-to-one correspondence'' (or ''[[bijection]]''), which is a [[function (mathematics)|function]] that maps between two sets such that each element of each set corresponds to a single element in the other set. This mathematical notion of "size", cardinality, is that two sets are of the same size if and only if there is a bijection between them. We call all sets that are in one-to-one correspondence with the integers ''countably infinite'' and say they have cardinality <math>\aleph_0</math>.
==Formal overview==
By definition, a set <math>{{mvar|S</math>}} is ''countable'' if there exists a [[bijection]] between <math>{{mvar|S</math>}} and a subset of the [[natural numbers]] <math>\N=\{0,1,2,\dots\}.</math>. For example, define the correspondence
<math display=block>
{{block indent|em=1.5|text=''a'' ↔ 1, ''b'' ↔ 2, ''c'' ↔ 3}}
a \leftrightarrow 1,\ b \leftrightarrow 2,\ c \leftrightarrow 3
Since every element of <math>S=\{a,b,c\}</math> is paired with ''precisely one'' element of <math>\{1,2,3\}</math>, ''and'' vice versa, this defines a bijection, and shows that <math>S</math> is countable. Similarly we can show all finite sets are countable. ▼
</math>
▲Since every element of <{{math >|1=''S '' = \ { ''a '', ''b '', ''c \''} }} </math> is paired with ''precisely one'' element of <{{math >\|{1, 2, 3 \} </math>, }} ''and'' vice versa, this defines a bijection, and shows that <math>{{mvar|S </math>}} is countable. Similarly we can show all finite sets are countable.
As for the case of infinite sets, a set <math>{{mvar|S</math>}} is countably infinite if there is a [[bijection]] between <math>{{mvar|S</math>}} and all of <math>{{tmath|\N</math>.}} As examples, consider the sets <{{math>|1=''A'' =\ {1, 2, 3,\dots\ ...}</math>,}} the set of positive [[integer]]s, and <{{math>|1=''B'' =\ {0, 2, 4, 6,\dots\ ...}</math>,}} the set of even integers. We can show these sets are countably infinite by exhibiting a bijection to the natural numbers. This can be achieved using the assignments {{math|''n'' ↔ ''n+1'' + 1}} and {{math|''n'' ↔ 2''n''}}, so that
<math display=block>\begin{align}
{{block indent|em=1.5|text=0 ↔ 1, 1 ↔ 2, 2 ↔ 3, 3 ↔ 4, 4 ↔ 5, ....}}
& 0 \leftrightarrow 1,\ 1 \leftrightarrow 2,\ 2 \leftrightarrow 3,\ 3 \leftrightarrow 4,\ 4 \leftrightarrow 5,\ \ldots \\[2pt]
{{block indent|em=1.5|text=0 ↔ 0, 1 ↔ 2, 2 ↔ 4, 3 ↔ 6, 4 ↔ 8, ....}}
& 0 \leftrightarrow 0,\ 1 \leftrightarrow 2,\ 2 \leftrightarrow 4,\ 3 \leftrightarrow 6,\ 4 \leftrightarrow 8,\ \ldots
\end{align}</math>
Every countably infinite set is countable, and every infinite countable set is countably infinite. Furthermore, any subset of the natural numbers is countable, and more generally:
The set of all [[ordered pair]]s of natural numbers (the [[Cartesian product]] of two sets of natural numbers, <math>\N\times\N</math> is countably infinite, as can be seen by following a path like the one in the picture: [[File:Pairing natural.svg|thumb|300px|The [[Cantor pairing function]] assigns one natural number to each pair of natural numbers]] The resulting [[Map (mathematics)|mapping]] proceeds as follows:
<math display=block>
{{block indent|em=1.5|text=0 ↔ (0, 0), 1 ↔ (1, 0), 2 ↔ (0, 1), 3 ↔ (2, 0), 4 ↔ (1, 1), 5 ↔ (0, 2), 6 ↔ (3, 0), ....}}
0 \leftrightarrow (0, 0),\ 1 \leftrightarrow (1, 0),\ 2 \leftrightarrow (0, 1),\ 3 \leftrightarrow (2, 0),\ 4 \leftrightarrow (1, 1),\ 5 \leftrightarrow (0, 2),\ 6 \leftrightarrow (3, 0),\ \ldots
</math>
This mapping covers all such ordered pairs.
This form of triangular mapping [[recursion|recursively]] generalizes to <math>{{mvar|n</math>}}-[[tuple]]s of natural numbers, i.e., <math>(a_1,a_2,a_3,\dots,a_n)</math> where <math>a_i</math>{{mvar|a{{sub|i}}}} and <math>{{mvar|n</math>}} are natural numbers, by repeatedly mapping the first two elements of an <math>{{mvar|n</math>}}-tuple to a natural number. For example, {{math|(0, 2, 3)}} can be written as {{math|((0, 2), 3)}}. Then {{math|(0, 2)}} maps to 5 so {{math|((0, 2), 3)}} maps to {{math|(5, 3)}}, then {{math|(5, 3)}} maps to 39. Since a different 2-tuple, that is a pair such as {{math|(''a'', ''b'')}}, maps to a different natural number, a difference between two {{mvar|n}}-tuples by a single element is enough to ensure the {{mvar|n}}-tuples being mapped to different natural numbers. So, an injection from the set of <math>{{mvar|n</math>}}-tuples to the set of natural numbers <math>{{tmath|\N</math>}} is proved. For the set of <math>{{mvar|n</math>}}-tuples made by the Cartesian product of finitely many different sets, each element in each tuple has the correspondence to a natural number, so every tuple can be written in natural numbers then the same logic is applied to prove the theorem.
{{math theorem | math_statement = The [[Cartesian product]] of finitely many countable sets is countable.<ref>{{Harvard citation no brackets|Halmos|1960|page=92}}</ref>{{efn|'''Proof:''' Observe that <math>\N\times\N</math> is countable as a consequence of the definition because the function <math>f:\N\times\N\to\N</math> given by <math>f(m,n)=2^m\cdot3^n</math> is injective.<ref>{{Harvard citation no brackets|Avelsgaard|1990|page=182}}</ref> It then follows that the Cartesian product of any two countable sets is countable, because if <math>{{mvar|A</math>}} and <math>{{mvar|B</math>}} are two countable sets there are surjections <math>f:\N\to A</math> and <math>g:\N\to B</math>. So <math>f\times g:\N\times\N\to A\times B</math>
is a surjection from the countable set <math>\N\times\N</math> to the set <math>A\times B</math> and the Corollary implies <math>A\times B</math> is countable. This result generalizes to the Cartesian product of any finite collection of countable sets and the proof follows by [[mathematical induction|induction]] on the number of sets in the collection.
}}}}
The set of all [[integer]]s <math>{{tmath|\Z</math>}} and the set of all [[rational number]]s <math>{{tmath|\Q</math>}} may intuitively seem much bigger than <math>{{tmath|\N</math>.}} But looks can be deceiving. If a pair is treated as the [[numerator]] and [[denominator]] of a [[vulgar fraction]] (a fraction in the form of <{{math>|''a''/''b</math>''}} where <math>{{mvar|a</math>}} and <{{math>|''b\neq'' ≠ 0</math>}} are integers), then for every positive fraction, we can come up with a distinct natural number corresponding to it. This representation also includes the natural numbers, since every natural number <math>{{mvar|n</math>}} is also a fraction <{{math>|''n''/1</math>}}. So we can conclude that there are exactly as many positive rational numbers as there are positive integers. This is also true for all rational numbers, as can be seen below.
{{math theorem | math_statement = <math>{{tmath|\Z</math>}} (the set of all integers) and <math>{{tmath|\Q</math>}} (the set of all rational numbers) are countable.{{efn|'''Proof:''' The integers <math>{{tmath|\Z</math>}} are countable because the function <math>f:\Z\to\N</math> given by <math>f(n)=2^n</math> if <math>{{mvar|n</math>}} is non-negative and <math>f(n)=3^{-n}</math> if <math>{{mvar|n</math>}} is negative, is an injective function. The rational numbers <math>{{tmath|\Q</math>}} are countable because the function <math>g:\Z\times\N\to\Q</math> given by <math>g(m,n)=\tfrac{m/(}{n+1)}</math> is a surjection from the countable set <math>\Z\times\N</math> to the rationals <math>{{tmath|\Q</math>.}} }}}}
In a similar manner, the set of [[algebraic number]]s is countable.<ref>{{Harvard citation no brackets|Kamke|1950|pages=3–4}}</ref>{{efn|1='''Proof:''' Per definition, every algebraic number (including complex numbers) is a root of a polynomial with integer coefficients. Given an algebraic number <math>\{{mvar|&alpha</math>;}}, let <math>a_0x^0 + a_1 x^1 + a_2 x^2 + \cdots + a_n x^n</math> be a polynomial with integer coefficients such that <math>\{{mvar|&alpha</math>;}} is the <math>{{mvar|k</math>}}-th root of the polynomial, where the roots are sorted by absolute value from small to big, then sorted by argument from small to big. We can define an injection (i. e. one-to-one) function <math>f:\mathbb{A}\to\Q</math> given by <math display=block>f(\alpha) = 2^{k-1} \cdot 3^{a_0} \cdot 5^{a_1} \cdot 7^{a_2} \cdots {p_{n+2}}^{a_n},</math>, where <math>p_n</math>{{mvar|p{{sub|n}}}} is the <math>{{mvar|n</math>}}-th [[prime number|prime]].}}
Sometimes more than one mapping is useful: a set <math>{{mvar|A</math>}} to be shown as countable is one-to-one mapped (injection) to another set <math>{{mvar|B</math>}}, then <math>{{mvar|A</math>}} is proved as countable if <math>{{mvar|B</math>}} is one-to-one mapped to the set of natural numbers. For example, the set of positive [[rational number]]s can easily be one-to-one mapped to the set of natural number pairs (2-tuples) because <math>p/q</math> maps to <{{math>|(p, q)</math>}}. Since the set of natural number pairs is one-to-one mapped (actually one-to-one correspondence or bijection) to the set of natural numbers as shown above, the positive rational number set is proved as countable.
{{math theorem | math_statement = Any finite [[union (set theory)|union]] of countable sets is countable.<ref>{{Harvard citation no brackets|Avelsgaard|1990|page=180}}</ref><ref>{{Harvard citation no brackets|Fletcher|Patty|1988|page=187}}</ref>{{efn|1='''Proof:''' If <math>A_i</math>{{mvar|A{{sub|i}}}} is a countable set for each <math>{{mvar|i</math>}} in <math>I=\{1,\dots,n\}</math>, then for each <math>{{mvar|n</math>}} there is a surjective function <math>g_i:\N\to A_i</math> and hence the function
<math display="block">G : I \times \mathbf{N} \to \bigcup_{i \in I} A_i,</math>
given by <math>G(i,m)=g_i(m)</math> is a surjection. Since <math>I\times \N</math> is countable, the union <math display="inline">\bigcup_{i \in I} A_i</math>is countable.
With the foresight of knowing that there are uncountable sets, we can wonder whether or not this last result can be pushed any further. The answer is "yes" and "no", we can extend it, but we need to assume a new axiom to do so.
{{math theorem | math_statement = (Assuming the [[axiom of countable choice]]) The union of countably many countable sets is countable.{{efn|1='''Proof''': As in the finite case, but <math>I=\N</math> and we use the [[axiom of countable choice]] to pick for each <math>{{mvar|i</math>}} in <math>{{tmath|\N</math>}} a surjection <math>g_i</math>{{mvar|g{{sub|i}}}} from the non-empty collection of surjections from <math>{{tmath|\N</math>}} to <math>A_i</math>{{mvar|A{{sub|i}}}}.}}}}
For example, given countable sets <{{math>\textbf{|'''a}''',\textbf{ '''b}''',\textbf{ '''c''', …}},\dots</math>
[[File:Countablepath.svg|thumb|300px|Enumeration for countable number of countable sets]]
Using a variant of the triangular enumeration we saw above:
<math display=block>a_0 \leftrightarrow 0,\ a_1 \leftrightarrow 1,\ b_0 \leftrightarrow 2,\ a_2 \leftrightarrow 3,\ b_1 \leftrightarrow 4,\ c_0 \leftrightarrow 5,\ a_3 \leftrightarrow 6,\ b_2 \leftrightarrow 7,\ c_1 \leftrightarrow 8,\ d_0 \leftrightarrow 9,\ a_4 \leftrightarrow 10,\ \ldots
*''a''<sub>0</sub> maps to 0
</math>
*''a''<sub>1</sub> maps to 1
*''b''<sub>0</sub> maps to 2
*''a''<sub>2</sub> maps to 3
*''b''<sub>1</sub> maps to 4
*''c''<sub>0</sub> maps to 5
*''a''<sub>3</sub> maps to 6
*''b''<sub>2</sub> maps to 7
*''c''<sub>1</sub> maps to 8
*''d''<sub>0</sub> maps to 9
*''a''<sub>4</sub> maps to 10
*...
This only works if the sets <{{math>\textbf{|'''a}''',\textbf{ '''b}''',\textbf{ '''c''', …}},\dots</math> are [[disjoint sets|disjoint]]. If not, then the union is even smaller and is therefore also countable by a previous theorem.
We need the [[axiom of countable choice]] to index ''all'' the sets <{{math>\textbf{|'''a}''',\textbf{ '''b}''',\textbf{ '''c''', …}},\dots</math> simultaneously.
{{math theorem | math_statement = The set of all finite-length [[sequence]]s of natural numbers is countable.}}
The elements of any finite subset can be ordered into a finite sequence. There are only countably many finite sequences, so also there are only countably many finite subsets.
{{math theorem | math_statement = Let <math>{{mvar|S</math>}} and <math>{{mvar|T</math>}} be sets.
# If the function <math>f:S\to T</math> is injective and <math>{{mvar|T</math>}} is countable then <math>{{mvar|S</math>}} is countable.
# If the function <math>g:S\to T</math> is surjective and <math>{{mvar|S</math>}} is countable then <math>{{mvar|T</math>}} is countable.}}
These follow from the definitions of countable set as injective / surjective functions.{{efn|'''Proof''': For (1) observe that if <math>{{mvar|T</math>}} is countable there is an injective function <math>h:T\to\N</math>. Then if <math>f:S\to T</math> is injective the composition <math>h\circ f:S\to \N</math> is injective, so <math>{{mvar|S</math>}} is countable.
For (2) observe that if <math>{{mvar|S</math>}} is countable, either <math>{{mvar|S</math>}} is empty or there is a surjective function <math>h:\N\to S</math>. Then if <math>g:S\to T</math> is surjective, either <math>{{mvar|S</math>}} and <math>{{mvar|T</math>}} are both empty, or the composition <math>g\circ h:\N\to T</math> is surjective. In either case <math>{{mvar|T</math>}} is countable.
}}
'''[[Cantor's theorem]]''' asserts that if <math>{{mvar|A</math>}} is a set and <math>\mathcal{P}(A)</math> is its [[power set]], i.e. the set of all subsets of <math>{{mvar|A</math>}}, then there is no surjective function from <math>{{mvar|A</math>}} to <math>\mathcal{P}(A).</math>. A proof is given in the article [[Cantor's theorem]]. As an immediate consequence of this and the Basic Theorem above we have:
{{math theorem | name = Proposition | math_statement = The set <math>\mathcal{P}(\N)</math> is not countable; i.e. it is [[uncountable]].}}
==Minimal model of set theory is countable==
If there is a set that is a standard model (see [[inner model]]) of ZFC set theory, then there is a minimal standard model (see [[Constructible universe]]). The [[Löwenheim–Skolem theorem]] can be used to show that this minimal model is countable. The fact that the notion of "uncountability" makes sense even in this model, and in particular that this model ''{{mvar|M''}} contains elements that are:
* subsets of ''{{mvar|M''}}, hence countable,
* but uncountable from the point of view of ''{{mvar|M''}},
was seen as paradoxical in the early days of set theory, see [[Skolem's paradox]] for more.
Countable sets can be [[total order|totally ordered]] in various ways, for example:
*[[Well-order]]s (see also [[ordinal number]]):
**The usual order of natural numbers {{math|(0, 1, 2, 3, 4, 5, ...…)}}
**The integers in the order {{math|(0, 1, 2, 3, ...…; −1, −2, −3, ...…)}}
*Other (''not'' well orders):
**The usual order of integers {{math|(...…, −3, −2, −1, 0, 1, 2, 3, ...…)}}
**The usual order of rational numbers (Cannotcannot be explicitly written as an ordered list!)
In both examples of well orders here, any subset has a ''least element''; and in both examples of non-well orders, ''some'' subsets do not have a ''least element''.
|