Cantor's diagonal argument Created 2026-09-24 Updated 2026-10-14
Cantor's diagonal argument shows that the set of all infinite binary sequences is an uncountable set. Suppose a proposed enumeration is , where is coordinate of row . Construct a new binary sequence by
It differs from row at coordinate , for every . It is consequently absent from the entire proposed list, regardless of how that list was chosen. The failure of an enumeration of all binary sequences follows from this precise point of disagreement, rather than from a claim that the list looks too small.
Figure 1.
Flipping the nth coordinate of the nth row constructs a binary sequence missing from every proposed row
. Details.
For the displayed window, the first six diagonal bits are , so the new sequence starts . The drawing shows only finitely many rows, but the rule defines every coordinate and excludes every row of an infinite list. This distinguishes the argument from the Cantor pairing function: that construction lists all pairs of finite indices, whereas this one concerns an entire infinite sequence as each object to be listed. Finite binary strings form a countable set; all infinite binary sequences do not.
The connection with power sets is exact: a subset corresponds to its indicator function, with a one in position exactly when . Changing the diagonal membership bit is the same mechanism as the Cantor's theorem construction . This reusable method turns a purported complete list into an explicit omitted object.
In his paper [ref], presented in 1891 and printed in the 1890–91 volume in 1892, Cantor uses infinite sequences of two symbols for the diagonal construction and then gives the broader comparison of cardinalities. The binary notation here is a modern presentation of that construction.
Countable set Created 2026-09-24 Updated 2026-10-14
A countable set is a set that admits an injective function into the natural numbers. It is therefore either a finite set or a countably infinite set.
For a countably infinite set, countability means that its members can be arranged as a sequence in which every member occurs exactly once. The order need not resemble the order already present in the set. For example, the integers can be listed as . Simply increasing through positive values would never reach a negative one.
The Cartesian product needs a similar change of strategy. Listing a whole horizontal row first would never finish that row, so later rows would be missed. Instead list pairs by increasing coordinate sum , and within each finite diagonal by increasing :
Every pair has a finite coordinate sum and therefore appears after finitely many earlier pairs. This is the construction made explicit by the Cantor pairing function. It explains why having two infinite coordinates does not, by itself, mean a larger cardinality.
Figure 1.
Enumerating natural-number pairs along finite diagonals reaches every point of the infinite grid
. Details.
Countable union of explicitly ordered finite lists without choice Created 2026-10-05 Updated 2026-10-06
Given finite lists in a set , their union of entries has an explicit enumeration from a subset of : use the existing positions in each list and a Cantor pairing function. If the union is infinite, successively take the first occurrence of an entry not previously taken, in the order of its natural-number code. The well-order on natural numbers makes each step uniquely determined and yields an injection . No axiom of choice is needed. This does not assert that an arbitrary countable family of unordered finite sets has a countable union in ZF without the axiom of choice.
Foundations of mathematics Created 2026-09-24 Updated 2026-10-13
Foundations of mathematics asks what our objects mean, what we assume about them, and why an argument establishes its conclusion. Set theory gives a common language for collections and functions; mathematical logic makes the structure of statements and deductions precise. A mathematical definition fixes a meaning, an axiom supplies an assumption, and a mathematical proof explains what follows. Separating these roles makes results reusable: once the group axioms are enough for a conclusion, that conclusion applies to every group, regardless of how its members are represented.
The assumptions can change the answer to a familiar calculation. Over the real numbers, factors as , so is zero or one. The same reasoning holds in any integral domain, because a product can be zero only when a factor is zero. In the ring of integers modulo six, however, and : there are four solutions, represented by . The extra solutions are idempotents, and the failed step involves zero divisors. Writing the domain is part of explaining the answer.
This precision also reveals surprising possibilities. A two-dimensional grid of natural numbers is a countable set, while all infinite binary sequences form an uncountable set. The Cantor pairing function supplies a complete enumeration of the first; Cantor's diagonal argument defeats every proposed enumeration of the second. Both arguments are short, yet distinguish two sizes of infinity. The subject's appeal is this ability to turn a vague question into one whose assumptions, construction, and limits can all be inspected.
Pairing function Created 2026-10-03 Updated 2026-10-14
A pairing function is a computable function that gives a bijection from the Cartesian product to , with two computable functions recovering its coordinates. Here consists of the natural numbers, including zero. If is the pairing function and its decoding functions, the requirements are
Every ordered pair has exactly one code, every code represents an ordered pair, and decoding always terminates. For a bijection given by a total computable function, computability of the inverse function also follows by enumerating all ordered pairs until the one with code appears. A primitive recursive pairing function makes the stronger requirement that both encoding and coordinate decoding are primitive recursive.
The Cantor pairing function makes this concrete through triangular numbers:
On the diagonal , list . There are ordered pairs there, and ordered pairs on earlier diagonals. Their codes therefore occupy precisely the consecutive natural numbers from through . These intervals touch without overlapping and cover all natural numbers; within each interval the offset determines the ordered pair. This proves both injectivity and surjectivity, hence the bijection. It also explains why the infinite grid is a countably infinite set: every ordered pair is reached after finitely many steps. A row-by-row listing would never finish its first infinite row. Authored treatments give the same diagonal construction with the coordinates exchanged.[ref]
For example, the Cantor pairing function gives
The order of the coordinates matters: and are different ordered pairs with different codes.
Figure 1.
The Cantor pairing function on a finite window: labels are codes, and the first 21 ordered pairs fill diagonals zero through five
. Details.
To decode a natural number , find the unique diagonal index satisfying
The inequality gives , so both recovered coordinates are natural numbers. At , , hence , , and . At , and both coordinates are zero. Solving the quadratic inequality gives the equivalent floor function expression
This is exact as a statement about the real numbers and their square roots. An implementation using floating-point arithmetic can round across a diagonal boundary, especially for large . Use an exact integer square root instead: with computed using integer arithmetic, . Alternatively, search for the diagonal using exact integer comparisons. The primitive recursive pairing function proof below uses bounded minimization and needs no approximate square root.
A pairing function is a reversible encoding: unlike a hash function mapping arbitrarily many inputs into a fixed finite range, it loses no coordinates. This works because the mathematical natural numbers have no upper bound. A machine word with binary digits has possible values, while two such words have possible ordered pairs; a bijection into one word of the same width is impossible. Evaluating the Cantor pairing function in a fixed-width integer type can overflow, including in the intermediate product . Exact implementation requires sufficiently large integer storage or an explicit restricted input range. One mathematical code need not occupy fewer binary digits than its two inputs.
Iterating a pairing function gives a reversible encoding of tuples of any fixed positive length. With the left-nesting convention, the Cantor pairing function encodes as
Decode the outer ordered pair first: gives . Decode its first coordinate to recover , giving the nested ordered pair and thus the original tuple .
Figure 2.
Decoding a known three-entry tuple: first unpair 257 into (18, 4), then unpair 18 into (2, 3)
. Details.
The tuple length and nesting convention must be known. The same code represents as a two-entry tuple and as a three-entry tuple; nesting alone does not make variable-length tuples self-describing. To encode variable-length tuples, supply their length or another explicit termination convention as part of the encoding. This simple change of representation is useful in computability theory and Gödel numbering: a function of several natural numbers can be studied through a single numerical input, while all coordinates remain recoverable. The striking fact is that a whole infinite grid can be serialized without omitting a point.
A historical reference for comparing sets through bijections is Georg Cantor's paper Ein Beitrag zur Mannigfaltigkeitslehre, published in 1878 in volume 84 of Journal für die reine und angewandte Mathematik, pages 242–258.[ref]
Constant sequences give an injection . For the opposite bound fix an enumeration of the rational numbers and encode a sequence by
Distinct sequences differ at some coordinate ; density of the rational numbers then makes their encoded sets differ at a pair . Thus is injective. The Cartesian product is countable; for example the Cantor pairing function
is a bijection with . Consequently is equinumerous with , already equinumerous with . Apply Cantor-Schröder-Bernstein theorem to obtain
False. Take , , and . Then
For example the Cantor pairing function bijects with . Thus the exponent increases strictly while the cardinal power remains the same. This counterexample is completely choice-free.
Use the inclusive convention: a set is countable if it admits an injective function into . This includes every finite set and the empty set. If is injective and , its restriction to is still injective, proving directly that every subset of a countable set is countable.
Enumerate pairs by diagonals. The positive-integer Cantor pairing function
is a bijection : on the diagonal , its values are through , each once, and these consecutive blocks partition . This proves countability without assuming any product theorem.
For a sequence of countable sets , choose injections . For in their union, let be the least index containing . The map
is injective: its encoded index and the injective within-set code recover . Thus a countable union of countable sets is countable. Selecting the injections for an arbitrary given family uses the usual axiom of countable choice; when the encodings are supplied, the displayed construction is entirely explicit.
For finite Cartesian powers, start with the identity injection on and recursively encode as . This proves that is countable for every positive integer and is the constructive proof of the finite Cartesian power of a countable set property.
For each positive integer , let consist of the functions for which is a period. Restriction to the residues is a bijection : any tuple extends uniquely to all of by taking residues modulo , including negative arguments. Hence is countable. Every periodic function belongs to some , so
There is no need to assume the chosen period is minimal; multiple descriptions only create overlap, which does not invalidate the union argument. This is an instance of the cardinality of integer-periodic function spaces principle.
A countable set is one admitting an injection into ; this includes finite sets and the empty set. An infinite countable set can equivalently be listed in a sequence indexed by .
For a countable union of countable sets , choose an injection for each nonempty . Assign the pair , where is the least index with . This is an injection into . The pairs are countable by diagonal enumeration; explicitly, with natural numbers starting at one, the Cantor pairing function
maps them bijectively to . Composing the two maps proves that the union is countable. Empty members contribute no elements.
To prove uncountability of the power set , suppose all subsets could be listed as . Define
For every , differs from on whether it contains . Thus is missing from the supposedly exhaustive list. This Cantor diagonal argument proves is uncountable.
For increasing functions in the question's non-strict sense, encode every subset by
where the value at zero is only a convenient auxiliary convention. Then
Each is even strictly increasing, hence is a nondecreasing function as required, and its successive differences recover uniquely. This is an injection from the uncountable power set into the requested collection. Therefore the increasing functions form an uncountable set.
For a decreasing function in the question's sense, is a nonincreasing function with positive integer values. Each strict decrease lowers its value by at least one, so there can be at most strict decreases. There is consequently a final drop, after which the function is constant. Every such function is determined by a finite initial list whose final value repeats forever. The set of all these lists is contained in
a countable union of countable sets, hence countable by the result just proved. Thus the decreasing functions form a countable set. These contrasting cardinalities of monotone natural-number functions come from the absence of an upper bound for increasing values and the finite number of drops available to decreasing natural-number values. If the natural numbers include zero, the same proof uses the bound instead.
A set is countable if it admits an injection into the natural numbers; this includes finite sets and the empty set. Use for the enumeration. The Cantor pairing function
is a bijection . Indeed, on the diagonal , its values are the consecutive integers from through . These intervals are disjoint, and the next starts one beyond the preceding endpoint. Every nonnegative integer therefore determines exactly one diagonal , then exactly one , and finally . If one's convention starts the natural numbers at one, translate both coordinates by one. Thus is a countable set.
For countable sets , choose injections and . The map is an injection, proving their Cartesian product is countable. Repeating this proves that every finite Cartesian power of a countable set is countable.
For a sequence of countable sets , choose an injection for each . For , let be the least index containing . The map
is an injection: its value recovers and then . This proves the countable union of countable sets theorem. Selecting all uses the usual axiom of countable choice; if enumerations are already supplied, the construction itself needs no additional choices.
We work in the ambient theory ZFC for this question. Write , using the transitive closure convention that contains and all its membership descendants.
First construct a set containing exactly the intended objects. If is a countable set, apply well-founded induction to membership on this transitive set. If all members of have countable set-theoretic rank, then
Indeed is countable, and a countable union of countable sets is countable in ZFC. The induction therefore gives . The collection
is now a genuine set by the axiom schema of separation inside the cumulative hierarchy level , and it contains every hereditarily countable set. It is a transitive set, since implies .
If is a countable subset of , then
The right side is countable, so . Thus has countable-subset closure. This proves existence of a set with the required closure before taking any intersection.
To make the least-set argument precise, form the nonempty set
It is a subset of and contains . Its intersection is also closed: a countable subset of is a countable subset of every and therefore belongs to each such . For any set with the prescribed closure, , whence . This is leastness among all such sets, not just among subsets of .
Finally, well-founded induction on shows for every such : when all members of are in , the countable set is a countable subset of , so . Hence , proving that the definition gives precisely
For the cardinal bound, code the entire countable membership ancestry. A code is a triple , where , is a well-founded relation and an extensional relation, and is distinguished. There are at most such codes: and are coded by subsets of countable sets, and a Cantor pairing function with finitely many tags codes the triple as a subset of .
The well-founded recursion
defines its collapse, as in the Mostowski collapse theorem. The range is countable and transitive; thus each decoded belongs to . Conversely, for , choose a bijection and the point with . Set exactly when . Transitivity of makes this relation extensional, and Axiom of foundation makes it well-founded. The recursion then gives , so this code decodes to .
We have a surjection from a set of at most continuum many codes onto . Using the permitted axiom of choice, well-order the codes and assign each its least code; this is an injection. In fact every subset of is hereditarily countable, giving the reverse bound as well:
Every member has rank below , while every countable ordinal belongs to and has rank . Consequently
The axioms hold except Power Set. axiom of extensionality and Axiom of foundation are inherited by this transitive structure. The empty set and belong to it, giving the empty-set axiom and the axiom of infinity. The axiom of pairing follows from countable-subset closure. For , is a countable subset of , giving the Axiom of union. Any subset of is countable and lies in , so the axiom schema of separation holds for all formulas interpreted in .
For the Axiom schema of replacement, let a formula interpreted in assign a unique to each . Relativize that formula to the set and use the ambient Axiom schema of replacement to collect its range. The range is countable and consists of members of , hence belongs to . The same argument, selecting one witness for each member of the countable domain, proves axiom schema of collection. An ambient choice function on a family has a countable graph of ordered pairs of hereditarily countable sets. Each such pair is in , and countable-subset closure puts the graph in , proving the internal axiom of choice.
However, all external subsets of are elements of . An internal power set of would therefore have to be the full external , by transitivity and absoluteness of subset membership. That is uncountable by Cantor's theorem, whereas every member of is countable. Thus the axioms satisfied by hereditarily countable sets are
Here the asserted axiom list includes both Axiom schema of replacement and axiom schema of collection; no equivalence relying on Power Set is being silently invoked.
Use “countable” to include finite and empty sets: a countable set admits an injection into . If and is injective, restricting to proves that is a countable set.
For a countable union of countable sets, index the family as and choose an injection for each member. For an element of the union, let be the least index containing it, and assign
This is injective: equality of the pair gives the same set index and then the same element. Finally the Cantor pairing function
injects into . The union is therefore countable. The proof uses chosen injections for the family, as in the usual set-theoretic framework with axiom of countable choice.
Choose injections and . The map is an injection into the countable set . Composing with the Cantor pairing function gives an injection into . Thus the Cartesian product of two countable sets is countable, including the case of an empty factor.
Choose an injection . For each , its fiber under the surjection is nonempty, so define
Two distinct fibers cannot contain the same label , because is an injection and has a single value. Thus is an injection, proving that is a countable set. Taking the least label avoids any need for a separate choice of one element from each fiber. If is empty, surjectivity makes empty as well.
For the unheaded enumeration request, list pairs of positive natural numbers by their sum. An explicit Cantor pairing function is
For , the positive integers give the consecutive labels . These blocks are disjoint, consecutive and cover . Consequently is a bijection from to , so is countable.
Work in ZF with the law of excluded middle, without the axiom of choice. The paper's terminology is an infinite Dedekind-finite set. The useful common principle is countable union of explicitly ordered finite lists without choice: given an actual sequence of finite lists, enumerate their entries by list number and position using a Cantor pairing function. If the union of entries is infinite, repeatedly take the entry with the least code not already selected. This produces an injection from without choosing any enumerations of unordered sets.
Consequently, if a family of objects has an explicitly ordered finite list of labels for each object, and only finitely many objects can be made from any given finite pool of labels, then a countably infinite list of distinct objects forces a countably infinite subset of the label set. For a Dedekind-finite label set this is impossible. If the label set embeds into the object family as well, infinitude is preserved. Thus
The distinction between ordered lists supplied by the data and arbitrary finite subsets is essential: a blanket countable-union theorem for unordered finite sets would introduce a choice principle.
A set is countable when it is finite or admits a bijection with a subset of ; equivalently, its elements can be listed in a sequence. The integers are countable, for example in the order . Enumerating pairs by diagonals, or applying the Cantor pairing function, then shows that is countable.
Suppose instead that the power set had an enumeration . The Cantor diagonal argument forms
For every , the set differs from at the element , so it is absent from the alleged enumeration. Therefore
Write the sets as , and list each nonempty countable set as . Enumerate the pairs along successive diagonals, as in the Cantor pairing function, and output when it has not appeared before. Every member of eventually appears, proving that a countable union of countable sets is countable.
List pairs by increasing value of , and within each diagonal by increasing :
Every pair occurs after finitely many earlier diagonals. More explicitly, the Cantor pairing function
is an injection . Hence is countable.
Primitive recursive pairing function Created 2026-10-06 Updated 2026-10-14
A primitive recursive pairing function is a pairing function whose encoding function and both coordinate functions of its inverse function are primitive recursive functions. Thus the bijection can be used in either direction inside a construction by primitive recursion and function composition in recursion theory. A decoder that is merely a computable function would not establish this stronger closure property. Sutner's definition of a primitive recursive pairing system explicitly includes the decoding functions; his more general systems need only be injective, whereas a pairing function here is a bijection.[ref]
The Cantor pairing function is a primitive recursive pairing function. For its encoding, construct the triangular numbers directly by primitive recursion:
Since addition is primitive recursive, so are and by primitive recursion and function composition in recursion theory. This establishes the claim without treating division by two as an unexplained primitive operation.
For decoding, use bounded minimization to define
The bound is valid for every natural number : , so the candidate always succeeds. The search includes zero; when , it immediately returns . If , the preceding candidate failed, which gives ; when , that lower inequality follows from . Thus this search finds exactly the diagonal in the Cantor pairing function inverse, with
The comparison is primitive recursive, and bounded minimization of a primitive recursive predicate is primitive recursive. Therefore is a primitive recursive function. Recover the coordinates by
In constructions on the natural numbers, implement these subtractions using the primitive recursive operation : apply the predecessor function times to by primitive recursion. On these inputs it agrees with ordinary subtraction, since the diagonal inequalities imply . Consequently and are primitive recursive functions, and . Zimmermann proves the relevant closure under bounded minimization and the primitive recursive character of the Cantor encoding and coordinate decoding; his convention adds the first coordinate, so its coordinates are exchanged relative to here.[ref]
For a worked bounded minimization, take . Candidates give , none exceeding . Candidate gives , so , , and . The search bound was ; it terminates much earlier in this example. The bound proves membership in the primitive recursive functions; it is not a claim that scanning all candidates is the fastest implementation.
For each fixed , define a tuple encoder by
Each and each coordinate decoder is primitive recursive, by finitely many applications of function composition in recursion theory to . For the three-entry tuple encoded as , applying returns , applying returns , and then , . The tuple length remains part of the agreed convention, as explained for a general pairing function.
This makes primitive recursive pairing functions useful for encoding several evolving values as one state in primitive recursion. For example, store consecutive Fibonacci numbers as and update by
The codes start , decoding to . Every step uses primitive recursive encoding, decoding and addition; a single numerical state therefore carries the two values needed for the next step. This is also the reason a suitable Gödel numbering should permit sufficiently simple decoding: representation should preserve the class of functions being studied.
Set theory Created 2026-09-24 Updated 2026-10-18
Set theory studies sets, their set elements, and the constructions and sizes possible for them. It supplies a shared vocabulary for mathematics: a function connects two sets, a binary relation specifies which pairs of objects are related, and a probability space starts with a set of possible outcomes. Giving these objects a common language lets a construction from one subject be used in another without repeating its underlying bookkeeping.
A particularly beautiful question is how to compare sizes without first assigning a number. Two sets have the same cardinality when a bijection pairs every member of one with exactly one member of the other. For finite sets, this agrees with ordinary counting. For infinite sets, it produces surprises: bijects the natural numbers with the nonnegative even integers, and the Cantor pairing function bijects the Cartesian product with . A proper subset can have the same cardinality as its containing set.
This does not make all infinite sets equally large. Cantor's diagonal argument shows that all infinite binary sequences cannot be listed by the natural numbers. Cantor's theorem gives the wider principle: the power set of any set has strictly greater cardinality. The contrast between an explicit enumeration and an impossibility argument makes the meaning of infinity much sharper than a picture of something merely continuing forever.
Set formation itself requires care. Russell's paradox shows why not every condition defines a set of all objects satisfying it. Zermelo–Fraenkel set theory instead uses axioms specifying permitted constructions, including set comprehension within a previously given set. The restrictions are useful: they let us form the collections ordinary arguments need while blocking the unrestricted construction that produces the paradox.