Rational arithmetic all works together

We have seen [what the rational numbers are](https://arbital.com/p/4zx), and five things we can do with them:

- [addition](https://arbital.com/p/55m)
- [subtraction](https://arbital.com/p/56x)
- [multiplication](https://arbital.com/p/59s)
- [division](https://arbital.com/p/5jd)
- [comparison](https://arbital.com/p/5pk)

These might seem like five standalone operations, but in fact they all play nicely together in a particular way.
You don't need to know the fancy name, but here it is anyway: mathematicians say that the rationals **form an [ordered field](https://arbital.com/p/ordered_field)**, meaning that the five operations above:

- work in the rationals
- slot together, behaving in certain specific ways that make it easy to calculate

*You shouldn't bother learning this page particularly deeply, because none of the properties alone is very interesting; instead, try and absorb it as a whole.*

We've already seen the "instant rules" for manipulating the rationals, and where they come from.
Here, we'll first quickly define the rational numbers themselves, and all the operations above, in "instant rule" format, just to have them all here in one place.
Then we'll go through all the properties that are required for mathematicians to be able to say that the operations on rationals "play nicely together" in the above sense; and we'll be relying on the instant rules as our definitions, because they're totally unambiguous.
That way we can be much more sure that we're not making some small error.
(Relying on an intuition about how apples work could in theory lead us astray; but the rules leave no wiggle-room or scope for interpretation.)

The letters $a, b, c, d$ should be read as standing for integers (possibly positive, negative or $0$), and $b$ and $d$ should be assumed not to be $0$ (recalling that [it makes no sense](https://arbital.com/p/5jd) to divide by $0$).

- A **rational number** is a pair of [integers](https://arbital.com/p/53r), written as $\frac{a}{b}$, where $b$ is not $0$, such that $\frac{a}{b}$ is viewed as being the same as $\frac{c}{d}$ precisely when $a \times d = b \times c$. %%note:This is just the instant rule for subtraction, below, together with the assumption that $\frac{0}{x} = \frac{0}{y}$ for any $x, y$ nonzero integers; in particular, the assumption that $\frac{0}{b \times d} = \frac{0}{1}$ when $b, d$ are not $0$, which we will need later.%%
- Addition: $$\frac{a}{b} + \frac{c}{d} = \frac{a \times d + b \times c} {b \times d}$$
- Subtraction: $$\frac{a}{b} - \frac{c}{d} = \frac{a}{b} + \frac{-c}{d} = \frac{a \times d - b \times c}{b \times d}$$
- Multiplication: $$\frac{a}{b} \times \frac{c}{d} = \frac{a \times c}{b \times d}$$
- Division (where also $c$ is not $0$): $$\frac{a}{b} \big/ \frac{c}{d} = \frac{a}{b} \times \frac{d}{c} = \frac{a \times d}{b \times c}$$
- Comparison (where we write $\frac{a}{b}$ and $\frac{c}{d}$ such that both $b$ and $d$ are positive %%note:Remember, we can do that: if $b$ is negative, for instance, we may instead write $\frac{a}{b}$ as $\frac{-a}{-b}$, and the extra minus-sign we introduce has now flipped $b$ from being negative to being positive.%%): $\frac{a}{b} < \frac{c}{d}$ precisely when $\frac{c}{d}-\frac{a}{b}$ is positive: that is, when $$\frac{b \times c - a \times d}{b \times d} > 0$$
which is in turn when $$b \times c - a \times d > 0$$

To be super-pedantic, it is necessary to show that the rules above are "well-defined": for instance, you don't get different answers if you apply the rules using $\frac{2}{4}$ instead of $\frac{1}{2}$.
Concretely, for example, $$\frac{2}{4} + \frac{1}{3} = \frac{1}{2} + \frac{1}{3}$$ according to the instant rules.
It's actually true that they *are* well-defined in this sense, but we won't show it here; consider them to be exercises.

Additionally, each integer can also be viewed as a rational number: namely, the integer $n$ can be viewed as $\frac{n}{1}$, being "$n$ copies of the $\frac{1}{1}$-chunk".

The properties required for an "ordered field"—that is, a nicely-behaved system of arithmetic in the rationals—fall naturally into groups, which will correspond to main-level headings below.

[https://arbital.com/p/toc:](https://arbital.com/p/toc:)

# How addition behaves

## Addition always spits out a rational number %%note:Confucius say that man who run in front of bus get tired; man who run behind bus get exhausted. On the other hand, mathematicians say that the rationals are *closed* under addition.%%

You might remember a certain existential dread mentioned in the [intro to rational numbers](https://arbital.com/p/4zx): whether it made sense to add rational numbers at all.
Then we saw in [https://arbital.com/p/55m](https://arbital.com/p/55m) that in fact it does make sense.

However, in this page we are working from the instant rules above, so if we want to prove that "addition spits out a rational number", we actually have to prove the fact that $\frac{a \times d + b \times c} {b \times d}$ is a rational number; no mention of apples at all.

Remember, a rational number here (as defined by instant rule!) is a pair of integers, the bottom one being non-zero.
So we just need to check that $a \times d + b \times c$ is an integer and that $b \times d$ is a non-zero integer, where $a, b, c, d$ are integers and $b, d$ are also not zero.

But that's easy: the product of integers is integer, and the product of integers which aren't zero is not zero.

## There must be a rational $0$ such that adding $0$ to anything doesn't change the thing  %%note:Mathematicians say that there is an [https://arbital.com/p/-54p](https://arbital.com/p/-54p) for addition.%%

This tells us that if we want to stay where we are, but we absolutely must add something, then we can always add $0$; this won't change our answer.
More concretely, $\frac{5}{6} + 0 = \frac{5}{6}$.

Strictly speaking, I'm pulling a bit of a fast one here; if you noticed how, then *very* well done.
A rational number is a *pair* of integers, such that the bottom one is not $0$; and I've just tried to say that $0$ is our rational such that adding $0$ doesn't change rationals.
But $0$ is not a pair of integers!

The trick is to use $\frac{0}{1}$ instead.
Then we can verify that $$\frac{0}{1} + \frac{a}{b} = \frac{0 \times b + a \times 1}{1 \times b} = \frac{0 + a}{b} = \frac{a}{b}$$ as we require.

## Every rational must have an anti-rational under addition  %%note:Mathematicians say that addition is *invertible*.%%

Concretely, every rational $\frac{a}{b}$ must have some rational $\frac{c}{d}$ such that $\frac{a}{b} + \frac{c}{d} = \frac{0}{1}$.
We've [already seen](https://arbital.com/p/56x) that we can define $-\frac{a}{b}$ to be such an "anti-rational", but remember that in order to fit in with our instant rules above, $-\frac{a}{b}$ is also not a pair of integers; we should instead use $\frac{-a}{b}$.

Then $$\frac{a}{b} + \frac{-a}{b} = \frac{a \times b + (-a) \times b}{b \times b} = \frac{0}{b \times b}$$

Finally, we want $\frac{0}{b \times b} = \frac{0}{1}$; but this is immediate by the instant-rule definition of "rational number", since $0 \times 1 = 0 \times (b \times b)$ (both being equal to $0$).

## Addition doesn't care which way round we do it %%note:Mathematicians say that addition is [commutative](https://arbital.com/p/3jb).%%

Concretely, this is the fact that $$\frac{a}{b} + \frac{c}{d} = \frac{c}{d} + \frac{a}{b}$$
This is intuitively plausible because "addition" is just "placing apples next to each other", and if I put five apples down and then seven apples, I get the same number of apples as if I put down seven and then five.

But we have to use the instant rules now, so that we can be sure our definition is completely watertight.

So here we go: $$\frac{a}{b} + \frac{c}{d} = \frac{a \times d + b \times c}{b \times d} = \frac{c \times b + d \times a}{d \times b} = \frac{c}{d} + \frac{a}{b}$$
where we have used the fact that multiplication of *integers* doesn't care about the order in which we do it, and similarly addition of *integers*.

## Addition doesn't care about the grouping of terms %%note:Mathematicians say that addition is [associative](https://arbital.com/p/3h4).%%

Here, we mean that $$\left(\frac{a}{b} + \frac{c}{d}\right) + \frac{e}{f} = \frac{a}{b} + \left( \frac{c}{d} + \frac{e}{f} \right)$$
This is an intuitively plausible fact, because "addition" is just "placing apples next to each other", and if I put down three apples, then two apples to the right, then one apple to the left, I get the same number ($6$) of apples as if I had put down one apple on the left, then three apples in the middle, then two on the right.

But we have to use the instant rules now, so that we can be sure our definition is completely watertight.
So here goes, starting from the left-hand side:
$$\left(\frac{a}{b} + \frac{c}{d}\right) + \frac{e}{f} = \frac{a \times d + b \times c}{b \times d} + \frac{e}{f} = \frac{(a \times d + b \times c) \times f + (b \times d) \times e}{(b \times d) \times f}$$

Since addition and multiplication of *integers* don't care about grouping of terms, this is just $$\frac{a \times d \times f + b \times c \times f + b \times d \times e}{b \times d \times f}$$

Now going from the right-hand side:
$$\frac{a}{b} + \left( \frac{c}{d} + \frac{e}{f} \right) = \frac{a}{b} + \frac{c \times f + d \times e}{d \times f} = \frac{a \times (d \times f) + b \times (c \times f + d \times e))}{b \times (d \times f)}$$
and similarly we can write this $$\frac{a \times d \times f + b \times c \times f + b \times d \times e}{b \times d \times f}$$
which is the same as we got by starting on the left-hand side.

Since we showed that both the left-hand and the right-hand side are equal to the same thing, they are in fact equal to each other.

# How multiplication behaves

## Multiplication always spits out a rational number %%note:Mathematicians say that the rationals are *closed* under multiplication.%%
This one is very easy to show: $\frac{a}{b} \times \frac{c}{d} = \frac{a \times c}{b \times d}$, but $b \times d$ is not zero when $b$ and $d$ are not zero, so this is a valid rational number.

## There must be a rational $1$ such that multiplying a thing by $1$ doesn't change the thing %%note:Mathematicians say that multiplication has an [https://arbital.com/p/-54p](https://arbital.com/p/-54p).%%

From our motivation of what multiplication was ("do unto $\frac{a}{b}$ what you would otherwise have done unto $1$"), it should be clear that the number $1$ ought to work here.
However, $1$ is not strictly speaking a rational number according to the letter of the "instant rules" above; so instead we use $\frac{1}{1}$.

Then $$\frac{1}{1} \times \frac{a}{b} = \frac{1 \times a}{1 \times b} = \frac{a}{b}$$ since $1 \times n = n$ for any integer $n$.

## Every nonzero rational must have a corresponding rational such that when we multiply them, we get $1$ %%note:Mathematicians say that every nonzero rational has an *inverse*. (Multiplication is not quite *invertible*, because $0$ has no inverse.)%%

Using the instant rule, though, we can take our nonzero rational $\frac{a}{b}$ (where neither $a$ nor $b$ is zero; this is forced by the requirement that $\frac{a}{b}$ be nonzero), and use $\frac{b}{a}$ as our corresponding rational.
Then $$\frac{a}{b} \times \frac{b}{a} = \frac{a\times b}{b \times a} = \frac{a \times b}{a \times b} = \frac{1}{1}$$

## Multiplication doesn't care which way round we do it %%note:Mathematicians say that multiplication is [commutative](https://arbital.com/p/3jb).%%
This had its own section on the [multiplication page](https://arbital.com/p/59s), and its justification there was by rotating a certain picture.
Here, we'll use the instant rule:
$$\frac{a}{b} \times \frac{c}{d} = \frac{a \times c}{b \times d} = \frac{c \times a}{d \times b} = \frac{c}{d} \times \frac{a}{b}$$
where we have used that multiplication of *integers* doesn't care about order.

## Multiplication doesn't care about the grouping of terms %%note:Mathematicians say that multiplication is [associative](https://arbital.com/p/3h4).%%

This is much harder to see from our intuition, because while addition is a very natural operation ("put something next to something else"), multiplication is much less natural (it boils down to "make something bigger").
In a sense, we're trying to show that "make something bigger and then bigger again" is the same as "make something bigger by a bigger amount".
However, it turns out to be the case that multiplication *also* doesn't care about the grouping of terms.

Using the instant rule for multiplication, it's quite easy to show that $$\frac{a}{b} \times \left(\frac{c}{d} \times \frac{e}{f} \right) = \left(\frac{a}{b} \times \frac{c}{d} \right) \times \frac{e}{f}$$

Indeed, working from the left-hand side:
$$\frac{a}{b} \times \left(\frac{c}{d} \times \frac{e}{f} \right) = \frac{a}{b} \times \frac{c \times e}{d \times f} = \frac{a \times (c \times e)}{b \times (d \times f)}$$
which is $\frac{a \times c \times e}{b \times d \times f}$ because multiplication of *integers* doesn't care about the grouping of terms.

On the other hand, $$\left(\frac{a}{b} \times \frac{c}{d} \right) \times \frac{e}{f} = \frac{a \times c}{b \times d} \times \frac{e}{f} = \frac{(a \times c) \times e}{(b \times d) \times f} = \frac{a \times c \times e}{b \times d \times f}$$

These two are equal, so we have shown that the left-hand and right-hand sides are both equal to the same thing, and hence they are the equal to each other.

# How addition and multiplication interact

## Multiplication "filters through" addition %%note:Mathematicians say that multiplication *distributes over* addition.%%

What we will show is that $$\left(\frac{c}{d} + \frac{e}{f}\right) \times \frac{a}{b} = \left(\frac{a}{b} \times \frac{c}{d}\right) + \left(\frac{a}{b} \times \frac{e}{f}\right)$$

This is intuitively true: the left-hand side is "make $\frac{a}{b}$, but instead of starting out with $1$, start with $\left(\frac{c}{d} + \frac{e}{f}\right)$"; while the right-hand side is "make $\frac{a}{b}$, but instead of starting out with $1$, start with $\frac{c}{d}$; then do the same but start with $\frac{e}{f}$; and then put the two together".
If we draw out diagrams for the right-hand side, and put them next to each other, we get the diagram for the left-hand side.
(As an exercise, you should do this for some specific values of $a,b,c,d,e,f$.)

We'll prove it now using the instant rules.

The left-hand side is $$\left(\frac{c}{d} + \frac{e}{f}\right) \times \frac{a}{b} = \frac{c \times f + d \times e}{d \times f} \times \frac{a}{b} = \frac{(c \times f + d \times e) \times a}{(d \times f) \times b}$$
which is $\frac{c \times f \times a + d \times e \times a}{d \times f \times b}$.

The right-hand side is $$\left(\frac{a}{b} \times \frac{c}{d}\right) + \left(\frac{a}{b} \times \frac{e}{f}\right) = \frac{a \times c}{b \times d} + \frac{a \times e}{b \times f} = \frac{(a \times c) \times (b \times f) + (b \times d) \times (a \times e)}{(b \times d) \times (b \times f)} = \frac{(a \times c \times b \times f) + (b \times d \times a \times e)}{(b \times d \times b \times f)}$$
Notice that everything on the top has a $b$ in it somewhere, so we can use this same "filtering-through" property that we already know the *integers* have:
$$\frac{b \times [https://arbital.com/p/(](https://arbital.com/p/()}{b \times (d \times b \times f)}$$
And finally we know that multiplying a fraction's numerator and denominator both by $b$ doesn't change the fraction:
$$\frac{(a \times c \times f) + (d \times a \times e)}{d \times b \times f}$$

This is just the same as the left-hand side, after we rearrange the product terms.

# How comparison interacts with the operations

## How comparison interacts with addition
The founding principle for how we came up with the definition of "comparison" was that adding the same thing to two sides of a balance scale didn't change the balance.

In terms of the instant rules, that becomes: if $\frac{a}{b} < \frac{c}{d}$, then $\frac{a}{b} + \frac{e}{f} < \frac{c}{d} + \frac{e}{f}$.

But by our instant rule, this is true precisely when $$0 < \frac{c}{d} + \frac{e}{f} - (\frac{a}{b} + \frac{e}{f})$$ and since multiplication by $-1$ filters through addition, that is precisely when $$0 < \frac{c}{d} + \frac{e}{f} - \frac{a}{b} - \frac{e}{f}$$
which (since addition doesn't care about which way round we do the additions, and subtraction is just a kind of addition) is precisely when $$0 < \frac{c}{d} - \frac{a}{b} + \frac{e}{f} - \frac{e}{f}$$
i.e. when $0 < \frac{c}{d} - \frac{a}{b}$; i.e. when $\frac{a}{b} < \frac{c}{d}$.

## How comparison interacts with multiplication

The aim here is basically to show that we can't multiply two things and get an anti-thing.
Written out in the notation, we wish to show that if $0 < \frac{a}{b}$ and if $0 < \frac{c}{d}$ then $0 < \frac{a}{b} \times \frac{c}{d}$, since the test for anti-ness is "am I less than $0$?".

Since $0 < \frac{a}{b}$, there are two options: either both $a$ and $b$ are positive, or they are both negative.
(If one is negative and one is positive, then the fraction will be negative.)

Likewise either both $c$ and $d$ are positive, or both are negative.

So we have four options in total:

- $a, b, c, d$ are positive
- $a, b, c, d$ are negative
- $a, b$ are positive; $c, d$ are negative
- $a, b$ are negative; $c, d$ are positive.

In the first case, we have $\frac{a \times c}{b \times d}$ positive, because all of $a, b, c, d$ are.

In the second case, we have $a \times c$ positive and $b \times d$ also positive (because both are two negative integers multiplied together); so again the fraction $\frac{a \times c}{b \times d}$ is positive.

In the third case, we have $a \times c$ negative and $b \times d$ also negative (because both are a positive number times a negative number); so the fraction $\frac{a \times c}{b \times d}$ is a negative divided by a negative.
Therefore it is positive, because we can multiply the numerator and the denominator by $-1$ to turn it into a positive divided by a positive.

%%hidden(Example):
We'll consider $\frac{1}{3}$ and $\frac{-2}{-5}$.
Then the product is $\frac{1}{3} \times \frac{-2}{-5} = \frac{-2}{-15}$; but that is the same as $\frac{2}{15}$.
%%

In the fourth case, we can do the same as the above, or we can be a bit sneaky: using the fact from earlier that multiplication doesn't care about order, we can note that $\frac{a}{b} \times \frac{c}{d}$ is the same as $\frac{c}{d} \times \frac{a}{b}$.
But now $c$ and $d$ are positive, and $a$ and $b$ are negative; we've already shown (in the previous case) that if the first fraction is "positive divided by positive", and the second fraction is "negative divided by negative".
By swapping $a$ for $c$, and $b$ for $d$, we can use a result we've already proved to obtain this final case.

Hence we've shown all four possible cases, and so the final result follows.

Summary: We have seen various operations of arithmetic on the rational numbers; in fact the operations are not as stand-alone as they may have appeared at first, but they are part of a closely-knit structure.


Order of rational operations (Math 0)

Summary: When an expression from rational arithmetic is written out, evaluate anything in brackets first; then perform multiplication and division left-to-right; then perform addition and subtraction left-to-right.


Principal ideal domain

In [ring theory](https://arbital.com/p/3gq), an [https://arbital.com/p/-5md](https://arbital.com/p/-5md) is a **principal ideal domain** (or **PID**) if every [ideal](https://arbital.com/p/ideal_ring_theory) can be generated by a single element.
That is, for every ideal $I$ there is an element $i \in I$ such that $\langle i \rangle = I$; equivalently, every element of $I$ is a multiple of $i$.

Since ideals are [kernels](https://arbital.com/p/5r6) of [ring homomorphisms](https://arbital.com/p/ring_homomorphism) ([proof](https://arbital.com/p/5r9)), this is saying that a PID $R$ has the special property that *every* ring homomorphism from $R$ acts "nearly non-trivially", in that the collection of things it sends to the identity is just "one particular element, and everything that is forced by that, but nothing else".

# Examples

- Every [Euclidean domain](https://arbital.com/p/euclidean_domain) is a PID. ([Proof.](https://arbital.com/p/euclidean_domain_is_pid))
- Therefore $\mathbb{Z}$ is a PID, because it is a [Euclidean domain](https://arbital.com/p/euclidean_domain). (Its Euclidean function is "take the modulus".)
- Every [field](https://arbital.com/p/481) is a PID because every ideal is either the singleton $\{ 0 \}$ (i.e. generated by $0$) or else is the entire ring (i.e. generated by $1$).
- The [ring $F](https://arbital.com/p/polynomial_ring) over a field $F$ is a PID, because it is a Euclidean domain. (Its Euclidean function is "take the [degree](https://arbital.com/p/polynomial_degree) of the polynomial".)
- The ring of [Gaussian integers](https://arbital.com/p/gaussian_integer), $\mathbb{Z}[https://arbital.com/p/i](https://arbital.com/p/i)$, is a PID because it is a Euclidean domain. ([Proof](https://arbital.com/p/gaussian_integers_is_pid); its Euclidean function is "take the [norm](https://arbital.com/p/norm_complex_number)".)
- The ring $\mathbb{Z}[https://arbital.com/p/X](https://arbital.com/p/X)$ (of integer-coefficient polynomials) is *not* a PID, because the ideal $\langle 2, X \rangle$ is not principal. This is an example of a [https://arbital.com/p/-unique_factorisation_domain](https://arbital.com/p/-unique_factorisation_domain) which is not a PID.
- The ring $\mathbb{Z}_6$ is *not* a PID, because it is not an integral domain. (Indeed, $3 \times 2 = 0$ in this ring.)

There are examples of PIDs which are not Euclidean domains, but they are mostly uninteresting.
One such ring is $\mathbb{Z}[](https://arbital.com/p/\frac{1}{2})$. ([Proof.](http://www.maths.qmul.ac.uk/~raw/MTH5100/PIDnotED.pdf))

# Properties

- Every PID is a [https://arbital.com/p/-unique_factorisation_domain](https://arbital.com/p/-unique_factorisation_domain). ([Proof](https://arbital.com/p/principal_ideal_domain_has_unique_factorisation); this fact is not trivial.) The converse is false; see the case $\mathbb{Z}[https://arbital.com/p/X](https://arbital.com/p/X)$ above.
- In a PID, "[prime](https://arbital.com/p/5m2)" and "[irreducible](https://arbital.com/p/5m1)" coincide. ([Proof.](https://arbital.com/p/5mf)) This fact also characterises the [maximal ideals](https://arbital.com/p/maximal_ideal) of PIDs.
- Every PID is trivially [Noetherian](https://arbital.com/p/noetherian_ring): every ideal is not just *finitely* generated, but generated by a single element.

Summary: A principal ideal domain is an [https://arbital.com/p/-5md](https://arbital.com/p/-5md) in which every [ideal](https://arbital.com/p/ideal_ring_theory) has a single generator.


Kernel of ring homomorphism

Given a [https://arbital.com/p/-ring_homomorphism](https://arbital.com/p/-ring_homomorphism) $f: R \to S$ between [rings](https://arbital.com/p/3gq) $R$ and $S$, we say the **kernel** of $f$ is the collection of elements of $R$ which $f$ sends to the zero element of $S$.

Formally, it is $$\{ r \in R \mid f(r) = 0_S \}$$
where $0_S$ is the zero element of $S$.

# Examples

- Given the "identity" (or "do nothing") ring homomorphism $\mathrm{id}: \mathbb{Z} \to \mathbb{Z}$, which sends $n$ to $n$, the kernel is just $\{ 0 \}$.
- Given the ring homomorphism $\mathbb{Z} \to \mathbb{Z}$ taking $n \mapsto n \pmod{2}$ (using the usual shorthand for [https://arbital.com/p/-5ns](https://arbital.com/p/-5ns)), the kernel is the set of even numbers.

# Properties

Kernels of ring homomorphisms are very important because they are precisely [ideals](https://arbital.com/p/ideal_ring_theory). ([Proof.](https://arbital.com/p/5r9))
In a way, "ideal" is to "ring" as "[https://arbital.com/p/-576](https://arbital.com/p/-576)" is to "[group](https://arbital.com/p/3gd)", and certainly [subrings](https://arbital.com/p/subring_ring_theory) are much less interesting than ideals; a lot of ring theory is about the study of ideals.

The kernel of a ring homomorphism always contains $0$, because a ring homomorphism always sends $0$ to $0$.
This is because it may be viewed as a [https://arbital.com/p/-47t](https://arbital.com/p/-47t) acting on the underlying additive group of the ring in question, and [the image of the identity is the identity](https://arbital.com/p/49z) in a group.

If the kernel of a ring homomorphism contains $1$, then the ring homomorphism sends everything to $0$.
Indeed, if $f(1) = 0$, then $f(r) = f(r \times 1) = f(r) \times f(1) = f(r) \times 0 = 0$.

Summary: The kernel of a [https://arbital.com/p/-ring_homomorphism](https://arbital.com/p/-ring_homomorphism) is the collection of elements which the homomorphism sends to $0$.


0.999...=1

Although some people find it counterintuitive, the [decimal expansions](https://arbital.com/p/4sl) $0.999\dotsc$ and $1$ represent the same [https://arbital.com/p/-4bc](https://arbital.com/p/-4bc).

# Informal proofs

These "proofs" can help give insight, but be careful; a similar technique can "prove" that $1+2+4+8+\dotsc=-1$. They work in this case because the [https://arbital.com/p/-series](https://arbital.com/p/-series) corresponding to $0.999\dotsc$ is [https://arbital.com/p/-absolutely_convergent](https://arbital.com/p/-absolutely_convergent).

* \begin{align}
x &= 0.999\dotsc \newline
10x &= 9.999\dotsc \newline
10x-x &= 9.999\dotsc-0.999\dotsc \newline
9x &= 9 \newline
x &= 1 \newline
\end{align}

* \begin{align}
\frac 1 9 &= 0.111\dotsc \newline
1 &= \frac 9 9 \newline
&= 9 \times \frac 1 9 \newline
&= 9 \times 0.111\dotsc \newline
&= 0.999\dotsc
\end{align}

* The real numbers are [https://arbital.com/p/-dense](https://arbital.com/p/-dense), which means that if $0.999\dots\neq1$, there must be some number in between. But there's no decimal expansion that could represent a number in between $0.999\dots$ and $1$.

# Formal proof

This is a more formal version of the first informal proof, using the definition of [https://arbital.com/p/-4sl](https://arbital.com/p/-4sl).

%%hidden(Show proof):
$0.999\dots$ is the decimal expansion where every digit after the decimal point is a $9$. By definition, it is the value of the series $\sum_{k=1}^\infty 9 \cdot 10^{-k}$. This value is in turn defined as the [https://arbital.com/p/-limit](https://arbital.com/p/-limit) of the sequence $(\sum_{k=1}^n 9 \cdot 10^{-k})_{n\in\mathbb N}$. Let $a_n$ denote the $n$th term of this sequence. I claim the limit is $1$. To prove this, we have to show that for any $\varepsilon>0$, there is some $N\in\mathbb N$ such that for every $n>N$, $|1-a_n|<\varepsilon$.

Let's prove by [induction](https://arbital.com/p/5fz) that $1-a_n=10^{-n}$. Since $a_0$ is the sum of {$0$ terms, $a_0=0$, so $1-a_0=1=10^0$. If $1-a_i=10^{-i}$, then

\begin{align}
1 - a_{i+1} &= 1 - (a_i + 9 \cdot 10^{-(i+1)}) \newline
&= 1-a_i - 9 \cdot 10^{-(i+1)} \newline
&= 10^{-i} - 9 \cdot 10^{-(i+1)} \newline
&= 10 \cdot 10^{-(i+1)} - 9 \cdot 10^{-(i+1)} \newline
&= 10^{-(i+1)}
\end{align}

So $1-a_n=10^{-n}$ for all $n$. What remains to be shown is that $10^{-n}$ eventually gets (and stays) arbitrarily small; this is true by the [https://arbital.com/p/archimedean_property](https://arbital.com/p/archimedean_property) and because $10^{-n}$ is monotonically decreasing.
%%

# Arguments against $0.999\dotsc=1$

These arguments are used to try to refute the claim that $0.999\dotsc=1$. They're flawed, since they claim to prove a false conclusion.

* $0.999\dotsc$ and $1$ have different digits, so they can't be the same. In particular, $0.999\dotsc$ starts "$0.$," so it must be less than 1.

%%hidden(Why is this wrong?):
Decimal expansions and real numbers are different objects. Decimal expansions are a nice way to represent real numbers, but there's no reason different decimal expansions have to represent different real numbers.
%%

* If two numbers are the same, their difference must be $0$. But $1-0.999\dotsc=0.000\dotsc001\neq0$.

%%hidden(Why is this wrong?):
Decimal expansions go on infinitely, but no farther. $0.000\dotsc001$ doesn't represent a real number because the $1$ is supposed to be after infinitely many $0$s, but each digit has to be a finite distance from the decimal point. If you have to pick a real number to for $0.000\dotsc001$ to represent, it would be $0$.
%%

* $0.999\dotsc$ is the limit of the sequence $0.9, 0.99, 0.999, \dotsc$. Since each term in this sequence is less than $1$, the limit must also be less than $1$. (Or "the sequence can never reach $1$.")

%%hidden(Why is this wrong?):
The sequence gets arbitrarily close to $1$, so its limit is $1$. It doesn't matter that all of the terms are less than $1$.
%%

* In the first proof, when you subtract $0.999\dotsc$ from $9.999\dotsc$, you don't get $9$. There's an extra digit left over; just as $9.99-0.999=8.991$, $9.999\dotsc-0.999\dotsc=8.999\dotsc991$.

%%hidden(Why is this wrong?):
There are infinitely many $9$s in $0.999\dotsc$, so when you shift it over a digit there are still the same amount. And the "decimal expansion" $8.999\dotsc991$ doesn't make sense, because it has infinitely many digits and then a $1$.
%%


Ideals are the same thing as kernels of ring homomorphisms

In [ring theory](https://arbital.com/p/3gq), the notion of "[ideal](https://arbital.com/p/ideal_ring_theory)" corresponds precisely with the notion of "[kernel](https://arbital.com/p/5r6) of [https://arbital.com/p/-ring_homomorphism](https://arbital.com/p/-ring_homomorphism)".

This result is analogous to the fact from [group theory](https://arbital.com/p/3gd) that [normal subgroups](https://arbital.com/p/4h6) are the same thing as [kernels of group homomorphisms](https://arbital.com/p/49y) ([proof](https://arbital.com/p/4h7)).

# Proof

## Kernels are ideals

Let $f: R \to S$ be a ring homomorphism between rings $R$ and $S$.
We claim that the kernel $K$ of $f$ is an ideal.

Indeed, it is clearly a [https://arbital.com/p/-576](https://arbital.com/p/-576) of the ring $R$ when viewed as just an additive group %%note:That is, after removing the multiplicative structure from the ring.%% because $f$ is a *group* homomorphism between the underlying additive groups, and kernels of *group* homomorphisms are subgroups (indeed, *normal* subgroups). ([Proof.](https://arbital.com/p/4h7))

We just need to show, then, that $K$ is closed under multiplication by elements of the ring $R$.
But this is easy: if $k \in K$ and $r \in R$, then $f(kr) = f(k)f(r) = 0 \times r = 0$, so $kr$ is in $K$ if $k$ is.

## Ideals are kernels


Fundamental Theorem of Arithmetic

summary: The Fundamental Theorem of Arithmetic is a statement about the [natural numbers](https://arbital.com/p/45h); it says that every natural number may be decomposed as a product of [primes](https://arbital.com/p/4mf), and this expression is unique up to reordering the factors. It is an extremely important theorem, and it is the basis of the field of [https://arbital.com/p/-number_theory](https://arbital.com/p/-number_theory).

The Fundamental Theorem of Arithmetic states that every [https://arbital.com/p/-45h](https://arbital.com/p/-45h) (greater than or equal to $2$) may be expressed as a product of [prime numbers](https://arbital.com/p/4mf), and the product is unique up to reordering.

This theorem is one of the main reasons $1$ is not considered to be prime: indeed, if it were prime then $3 \times 5$ could be factorised into primes as $3 \times 5 \times 1$, but these would be two *different* factorisations of the number $15$.
The FTA's statement is much cleaner if $1$ is not thought of as prime.

In a more general context, the FTA says precisely that the [ring](https://arbital.com/p/3gq) $\mathbb{Z}$ is a [https://arbital.com/p/-unique_factorisation_domain](https://arbital.com/p/-unique_factorisation_domain); there is therefore a much more abstract proof than the elementary one we will present further on in this article:

- $\mathbb{Z}$ is a [Euclidean domain](https://arbital.com/p/euclidean_domain) (with Euclidean function given by "take the modulus");
- Therefore $\mathbb{Z}$ is a [https://arbital.com/p/-5r5](https://arbital.com/p/-5r5) ([proof](https://arbital.com/p/euclidean_domain_is_pid));
- And principal ideal domains are unique factorisation domains ([proof](https://arbital.com/p/principal_ideal_domain_has_unique_factorisation)).

# Examples

- The FTA does not talk about $0$ or $1$; this is because these numbers are conventionally considered neither prime nor composite.
- Even if we haven't bothered to calculate $17 \times 23 \times 23$, we can immediately say that it is odd. Indeed, by the FTA, $2$ cannot divide $17 \times 23^2$, because the complete list of prime factors of this number is $\{ 17, 23, 23\}$, and $2$ is prime.

# Proof

Timothy Gowers has an [excellent article](https://gowers.wordpress.com/2011/11/18/proving-the-fundamental-theorem-of-arithmetic/) about the proof of the FTA.

The FTA consists of two parts: we must show that every number can be decomposed as primes, and also that every number can be decomposed *uniquely*.

## Every number can be written as a product of primes

This part is the easier, and it uses [https://arbital.com/p/-strong_induction](https://arbital.com/p/-strong_induction) (a version of [proof by induction](https://arbital.com/p/5fz)).

Clearly $2$ can be written as a product of primes, because it *is* prime; so it can be written as just itself.

Now, for $n$ bigger than $2$, if $n$ is prime then we are immediately done (just write it as itself).
Otherwise, $n$ is not prime, so it can be written as $a \times b$, say, with $a$ and $b$ both less than $n$.

But by the inductive hypothesis, we can express $a$ and $b$ each as products of primes, so we can express $n$ as the combined product of the two sets of factors of $a$ and $b$.

%%hidden(Example):
Consider $n = 1274$.
We have two options: $n$ is prime or $n$ is composite.

It turns out that $n$ is actually equal to $49 \times 26$, so it's not prime.

By the inductive hypothesis, we can factor $49$ as a product of primes (indeed, it's $7^2$); and we can factor $26$ as a product of primes (indeed, it's $2 \times 13$); so we can factor $1274$ as $2 \times 7^2 \times 13$.

(If you like, you can view this as just "start again at $49$ instead of at $1274$, and spit out what you get; then start again at $26$ instead of $1274$, and spit out what you get; and finally combine the spittings-out"; no mention of a spooky "inductive hypothesis" at all.)

Note that at this point, we haven't any guarantee at all that this is the *only* prime factorisation; all we assert so far is that it is *a* prime factorisation.
%%

## Every number can be decomposed *uniquely* as a product of primes

For this, we will need a basic (but non-obvious and important) fact about the behaviour of prime numbers: [Euclid's lemma](https://arbital.com/p/5mh), which states that if a prime $p$ divides a product $ab$, then $p$ divides at least one of $a$ and $b$.

We will work by induction on $n$ again.
If $n = 2$ then the result is immediate: a number can only be divided by numbers which are not larger than it, but $1$ and $2$ are the only such numbers.

Suppose $n$ can be written as both $p_1 p_2 \dots p_r$ and $q_1 q_2 \dots q_s$, where each $p_i$ and $q_j$ is prime (but there might be repeats: maybe $p_1 = p_2 = q_3 = q_7$, for instance).
We need to show that $r=s$ and that (possibly after reordering the lists) $p_i = q_i$ for each $i$.

Certainly $p_1$ divides $n$, because it divides $p_1 p_2 \dots p_r$.
Therefore it divides $q_1 q_2 \dots q_s$, and hence it divides one of $q_1$ or $q_2 \dots q_s$, by Euclid's lemma.
Therefore either it divides $q_1$, or it divides one of $q_2$ or $q_3 \dots q_s$; by induction, $p_1$ divides some $q_i$.
Because we don't care about the ordering of the list, let us reorder the list if necessary so that in fact $i=1$: put the factor $q_i$ at the start of the list.

Now, $q_1$ is prime, and $p_1$ is not equal to $1$ but it divides $q_1$; hence $p_1 = q_1$.

Dividing through by $p_1$, then, we obtain $p_2 \dots p_r = q_2 \dots q_s$, a strictly smaller number; so by the inductive hypothesis, $r-1 = s-1$ (so $r=s$) and the unordered list of $p_i$ is the same as the unordered list of $q_i$ for $i \geq 2$.

This proves the theorem.

# Why is this not obvious?

Timothy Gowers has a [good piece](https://gowers.wordpress.com/2011/11/13/why-isnt-the-fundamental-theorem-of-arithmetic-obvious/) on why this result is not just obvious.
Of course, what is "obvious" and what is not "obvious" varies heavily depending on who you're talking to.
For this author personally, the true reason it's not obvious is Gowers's reason number 4: because there are very similar structures which do *not* have the property of unique factorisation.
(Gowers uses $\mathbb{Z}[https://arbital.com/p/\sqrt{-5}](https://arbital.com/p/\sqrt{-5})$; on the [page on irreducibles](https://arbital.com/p/5m1), we show that $\mathbb{Z}[https://arbital.com/p/\sqrt{-3}](https://arbital.com/p/\sqrt{-3})$ could be used just as well.)


Formal definition of the free group

The [https://arbital.com/p/-5kg](https://arbital.com/p/-5kg) may be constructed formally using van der Waerden's trick, which is not intuitive at all but leads to a definition that is very easy to work with. This page will detail van der Waerden's construction, and will prove that the trick yields a group which has all the right properties to be the free group.

# The construction

Write $X^r$ for the set that contains all the [freely reduced words](https://arbital.com/p/5jc) over $X \cup X^{-1}$ (so, for instance, excluding the word $aa^{-1}$). %%note:We use the superscript $r$ to denote "reduced".%%

We define the *free group* $F(X)$, or $FX$, on the set $X$ to be a certain [https://arbital.com/p/-576](https://arbital.com/p/-576) of the [https://arbital.com/p/-497](https://arbital.com/p/-497) $\mathrm{Sym}(X^r)$: namely that which is generated by the following elements, one for each $x \in X \cup X^{-1}$:

- $\rho_x : \mathrm{Sym}(X^r) \to \mathrm{Sym}(X^r)$, sending $a_1 a_2 \dots a_n \mapsto a_1 a_2 \dots a_n x$ if $a_n \not = x^{-1}$, and $a_1 a_2 \dots a_{n-1} x^{-1} \mapsto a_1 a_2 \dots a_{n-1}$.
- $\rho_{x^{-1}} : \mathrm{Sym}(X^r) \to \mathrm{Sym}(X^r)$, sending $a_1 a_2 \dots a_n \mapsto a_1 a_2 \dots a_n x^{-1}$ if $a_n \not = x$, and $a_1 a_2 \dots a_{n-1} x \mapsto a_1 a_2 \dots a_{n-1}$.

Recall that each $\rho_x$ lies in $\mathrm{Sym}(X^r)$, so each is a [https://arbital.com/p/-499](https://arbital.com/p/-499) from $X^r$ to $X^r$.
We specify it by stating what it does to every element of $X^r$ (that is, to every freely reduced word over $X$).

We first specify what it does to those words which don't end in $x^{-1}$: $\rho_x$ simply appends an $x$ to such words.
We then specify it to the remaining words, those which do end in $x^{-1}$: then $\rho_x$ just removes the $x^{-1}$.

It's easy to check that if $\rho_x$ is given a freely-reduced word as input, then it produces a freely-reduced word as output, because the only change to the word is at the end and we make sure to provide a separate definition if $x$ is to be cancelled.
Therefore each $\rho_x$ is a function $X^r \to X^r$.

Then we do it all again for all the inverses $x^{-1}$, creating the functions $\rho_{x^{-1}}$; and finally, we add in the [https://arbital.com/p/-54p](https://arbital.com/p/-54p), denoted $\rho_{\varepsilon}$, which simply returns its input unchanged.

Notice that the $\rho_x$ and $\rho_{x^{-1}}$ are all indeed bijective (and therefore members of $\mathrm{Sym}(X^r)$), because in fact $\rho_x$ and $\rho_{x^{-1}}$ are [inverse](https://arbital.com/p/4sn) to each other (each cancelling off what the other did), and a function with an inverse is bijective.

So, we've defined the free group as a certain subgroup of the symmetric group.
Remember that the subgroup has as its group operation "function composition"; so $\rho_x \cdot \rho_y = \rho_x \circ \rho_y$, for instance.
We will write $\rho_x \rho_y$ for this, omitting the group operation.

Something key to notice is that if we apply $\rho_{a_n} \rho_{a_{n-1}} \dots \rho_{a_1}$ to the empty word $\varepsilon$, we get $$\rho_{a_n} \rho_{a_{n-1}} \dots \rho_{a_1}(\varepsilon) = \rho_{a_n} \rho_{a_{n-1}} \dots \rho_{a_3}(\rho_{a_2}(a_1)) = \rho_{a_n a_{n-1} \dots a_3}(a_1 a_2) = \dots = a_1 a_2 \dots a_n$$
if $a_1 a_2 \dots a_n$ is a freely reduced word.
(Indeed, if the word is freely reduced then none of the successive $\rho_{a_i}, \rho_{a_{i+1}}$ can have cancelled each other's effect out, so every application of a $\rho_{a_i}$ must be appending a letter.)
Hence we might hope to have captured the freely reduced words in our subgroup.

# The formal definition is the same as the intuitive definition

We'll show that there is a bijection between the free group and the set of reduced words, by "converting" each reduced word into a corresponding member of the free group.

Take a reduced word, $w = a_1 a_2 \dots a_n$, and produce the member of the free group (that is, the function) $\rho_{a_1} \rho_{a_2} \dots \rho_{a_n}$. %%note:Recall that the group operation here is composition of functions, so this is actually the function $\rho_{a_1} \circ \rho_{a_2} \circ \dots \circ \rho_{a_n}$.%%
This really does produce a member of the free group (i.e. of the subgroup of the symmetry group), because each $a_i$ is an element of $X \cup X^{-1}$ and we have already specified how to make $\rho_{a_i}$ from such an element.

Now, we claim that in fact this map is injective: that is, we can't take two words $a_1 a_2 \dots a_n$ and $b_1 b_2 \dots b_m$ and produce the same member of the free group.
(That is, we show that $\rho_{a_1} \rho_{a_2} \dots \rho_{a_n} = \rho_{b_1} \rho_{b_2} \dots \rho_{b_m}$ implies $a_1 \dots a_n = b_1 \dots b_m$.)
Indeed, if the two functions ("elements of the free group") are equal, then they must in particular do the same thing when they are applied to the empty word $\varepsilon$.
But by the "key notice" above, when we evaluate $\rho_{a_1} \rho_{a_2} \dots \rho_{a_n}$ at the empty word, we get $a_n a_{n-1} \dots a_2 a_1$; and when we evaluate $\rho_{b_1} \rho_{b_2} \dots \rho_{b_m}$ at the empty word, we get $b_m b_{m-1} \dots b_2 b_1$; so the two words must be equal after all.

Finally, the map is surjective: we can make any member of the free group by "converting the appropriate reduced word into a function".
Indeed, the free group is generated by the $\rho_x$ and $\rho_{x^{-1}}$ for $x \in X$, so every element is some $\rho_{x_1} \dots \rho_{x_n}$ for some selection of $x_1, \dots, x_n \in X \cup X^{-1}$.
Note that $x_1 \dots x_n$ need not necessarily be freely reduced as a word at the moment; but if it is indeed not freely reduced, so some $x_i, x_{i+1}$ cancel each other out, then removing that pair completely doesn't change the function $\rho_{x_1} \dots \rho_{x_n}$.
For example, $\rho_{x_1} \rho_{x_1^{-1}} \rho_{x_2} = \rho_{x_2}$.
Hence the process of "performing one step of a free reduction" (i.e. removing a cancelling pair) doesn't change the member of the free group as a function; and since each such removal makes the word shorter, it must eventually terminate.
It remains to show that it doesn't matter in what order we remove the cancelling pairs; but that is immediate because we've already shown that our "conversion" process is injective: we started with a member of the free group, so if it corresponds to a freely reduced word then it corresponds to a *unique* freely reduced word.
Since we've just shown that it does indeed correspond to a freely reduced word (by repeatedly removing cancelling pairs), we are done.

The above shows that the free group can be considered just to be the set of reduced words.


Operations in Set theory

An operation in [set](https://arbital.com/p/3jz) theory is a [https://arbital.com/p/-3jy](https://arbital.com/p/-3jy) of two sets, that returns a set.

Common set operations include [Union ](https://arbital.com/p/5s8), [Intersection ](https://arbital.com/p/5sb), [Relative complement ](https://arbital.com/p/5sc), and [Cartesian product ](https://arbital.com/p/3xb).

![illustrations of the output of four basic set operations](https://imgh.us/basic_set_operations_1.svg)


Absolute Complement

The complement $A^\complement$ of a set $A$ is the set of all things that are not in $A$. Put simply, the complement is its opposite.

Where $U$ denotes the universe, $A^\complement = U \setminus A$. That is, $A^\complement$ is the [Relative complement](https://arbital.com/p/set_relative_complement) of $U$ and $A$.


Union

The union of two sets $A$ and $B$, denoted $A \cup B$, is the set of things which are either in $A$ or in $B$ or both.

![illustration of the output of the union operation](https://imgh.us/set_union.svg)

Formally stated, where $C = A \cup B$

$$x \in C \leftrightarrow (x \in A \lor x \in B)$$

That is, [https://arbital.com/p/46m](https://arbital.com/p/46m) $x$ is in the union $C$, then either $x$ is in $A$ or $B$ or possibly both.

%%todo: more lengthy explanation for [https://arbital.com/p/1r6](https://arbital.com/p/1r6) level%%

# Examples

 - $\{1,2\} \cup \{2,3\} = \{1,2,3\}$
 - $\{1,2\} \cup \{8,9\} = \{1,2,8,9\}$
 - $\{0,2,4,6\} \cup \{3,4,5,6\} = \{0,2,3,4,5,6\}$
 - $\mathbb{R^-} \cup \mathbb{R^+} \cup \{0\} = \mathbb{R}$ (In other words, the union of the negative reals, the positive reals and zero make up all of the [real numbers](https://arbital.com/p/4bc).)

Alexei Andreev
Eric Rogstad
Eric Bruylant
M Yass
Patrick Stevens
Joe Zeng


Intersection

The intersection of two sets $A$ and $B$, denoted $A \cap B$, is the set of elements which are in both $A$ and $B$.

![illustration of the output of an intersection](https://imgh.us/set_intersection_1.svg)

Formally stated, where $C = A \cap B$

$$x \in C \leftrightarrow (x \in A \land x \in B)$$

That is, [https://arbital.com/p/46m](https://arbital.com/p/46m) $x$ is in the intersection $C$, then $x$ is in $A$ and $x$ is in $B$.

For example,

 - $\{1,2\} \cap \{2,3\} = \{2\}$
 - $\{1,2\} \cap \{8,9\} = \{\}$
 - $\{0,2,4,6\} \cap \{3,4,5,6\} = \{4,6\}$


Relative complement

The relative complement of two sets $A$ and $B$, denoted $A \setminus B$, is the set of elements that are in $A$ while not in $B$.

![illustration of the output of a relative complement](https://imgh.us/set_relative_complement.svg)

Formally stated, where $C = A \setminus B$

$$x \in C \leftrightarrow (x \in A \land x \notin B)$$

That is, [https://arbital.com/p/46m](https://arbital.com/p/46m) $x$ is in the relative complement $C$, then $x$ is in $A$ and x is not in $B$.

For example,

 - $\{1,2,3\} \setminus \{2\} = \{1,3\}$
 - $\{1,2,3\} \setminus \{9\} = \{1,2,3\}$
 - $\{1,2\} \setminus \{1,2,3,4\} = \{\}$

If we name the set $U$ as the set of all things, then we can define the [Absolute complement](https://arbital.com/p/5s7) of the set $A$, $A^\complement$, as $U \setminus A$


Cantor-Schröder-Bernstein theorem

summary(Technical): The Cantor-Schröder-Bernstein theorem states that the [class](https://arbital.com/p/class_set_theory) of [cardinals](https://arbital.com/p/4w5) forms a [total order](https://arbital.com/p/540). (Though not a totally ordered *set*, because [there is no set of all cardinals](https://arbital.com/p/cardinals_form_a_proper_class)).

Recall that we say a [set](https://arbital.com/p/3jz) $A$ is *smaller than or equal to* a set $B$ if there is an [injection](https://arbital.com/p/4b7) from $A$ to $B$.
The set $A$ *has the same [size](https://arbital.com/p/4w5)* as $B$ if there is a [bijection](https://arbital.com/p/499) between $A$ and $B$.

The Cantor-Schröder-Bernstein theorem states that if $A$ is smaller than or equal to $B$, and $B$ is smaller than or equal to $A$, then $A$ and $B$ have the same size.
This tells us that the arithmetic of [cardinals](https://arbital.com/p/4w5) is well-behaved in that it behaves like a [total order](https://arbital.com/p/540).
It is similar to the arithmetic of the [natural numbers](https://arbital.com/p/45h) in that it can never be the case that simultaneously $a < b$ and $b < a$.

# Proofs

There are several proofs, some concrete and some less so.

## Concrete proof

A clear explanation of the intuition of this proof [has been written](https://www.math.brown.edu/~res/infinity.pdf) by Richard Evan Schwartz; see page 61 of the linked PDF, or search on the word "dog" (which appears in the first page of the explanation).
[The intuition is Math0 suitable.](https://arbital.com/p/comment:)

Let $f: A \to B$ and $g: B \to A$ be injections; we will define a bijective function $h: A \to B$.

Because $f$ is injective, if $f$ ever hits $b$ (that is, if there is $a \in A$ such that $f(a) = b$) then it is possible to define $f^{-1}(b)$ to be the *unique* $a \in A$ such that $f(a) = b$; similarly with $g$.
The slogan is "if $f^{-1}(a)$ exists, then it is well-defined: there is no leeway about which element we might choose to be $f^{-1}(a)$".

Fix some $a \in A$, and consider the sequence $$\dots, f^{-1}(g^{-1}(a)), g^{-1}(a), a, f(a), g(f(a)), \dots$$
Now, this sequence might not extend infinitely to the left; it may not even get past $a$ to the left (if $g^{-1}(a)$ doesn't exist, for instance). %%note:On the other hand, perhaps the sequence does extend infinitely to the left.%%
Also, the sequence might duplicate elements: it might be the case that $gfgf(a) = a$, for instance. %%note:And maybe there is a repeat somewhere to the left, too.%%

Similarly, we can fix some $b \in B$, and consider $$\dots g^{-1} f^{-1}(b), f^{-1}(b), b, g(b), f(g(b)), \dots$$

Every element of $A$, and every element of $B$, appears in one of these chains.
Moreover, if $a \in A$ appears in two different chains, then in fact the two chains are the same %%note:Though maybe we're looking at a different place on the same chain. If we compare the $g^{-1} f^{-1}(b)$-chain with the $b$-chain, we see they're the same chain viewed two different ways: one viewing is two places offset from the other viewing.%%, because each element of the chain specifies and is specified by the previous element in the chain (if it exists) and each element of the chain specifies and is specified by the next element of the chain.

So every element of $A$ and every element of $B$ is in exactly one chain.
Now, it turns out that there are exactly four distinct "types" of chain.

- It could extend infinitely in both directions without repeats. In this case, we define $h(a) = f(a)$ for each element of $A$ in the chain. (Basically assigning to each element of $A$ the element of $B$ which is next in the chain.)
- It could extend infinitely off to the right, but it has a hard barrier at the left, and has no repeats: the chain stops at an element of $A$. In this case, again we define $h(a) = f(a)$ for each element of $A$ in the chain. (Again, basically assigning to each element of $A$ the element of $B$ which is next in the chain.)
- It could extend infinitely off to the right, but it has a hard barrier at the left, and has no repeats: the chain stops at an element of $B$. In this case, we define $h(a) = g^{-1}(a)$ for each element of $A$ in the chain. (Basically assigning to each element of $A$ the element of $B$ which is *previous* in the chain.)
- It could have repeats. Then it must actually be a cycle of even length (unrolled into an infinite line), because each element of the chain only depends on the one before it, and because we can't have two successive elements of $A$ (since the elements are alternating between $A$ and $B$). In this case, we define $h(a) = f(a)$ for each element of $A$ in the chain. (Basically assigning to each element of $A$ the element of $B$ which is next in the chain.)

Have we actually made a bijection?
Certainly our function is well-defined: every element of $A$ appears in exactly one chain, and we've specified where every element of $A$ in any chain goes, so we've specified where every element of $A$ goes.

Our function is [surjective](https://arbital.com/p/4bg), because every element of $B$ is in a chain; if $b \in B$ has an element $a$ of $A$ before it in its chain, then we specified that $h$ takes $a$ to $b$, while if $b \in B$ is at the leftmost end of its chain, we specified that $h$ takes $g(b)$ (that is, the following element in the chain) to $b$.

Our function is injective.
Since the chains don't overlap, and the first three cases of "what a chain might look like" have no repeats at all, the only possible way an element of $B$ can be hit twice by $h$ is if that element lies in one of the cyclical chains.
But then to elements of $A$ in that chain, $h$ assigns the following element of $B$; so $b \in B$ is hit only by the preceding element of $A$, which is the same in all cases because the chain is a cycle.
%%note:The picture in the linked intuitive document makes this much clearer.%%

## Proof from the [Knaster-Tarski theorem](https://arbital.com/p/knaster_tarski_theorem)
This proof is very quick, but almost completely opaque.
It relies on the [Knaster-Tarski fixed point theorem](https://arbital.com/p/knaster_tarski_theorem), which states that if $X$ is a [complete poset](https://arbital.com/p/complete_poset) and $f: X \to X$ is [order-preserving](https://arbital.com/p/order_preserving_map), then $f$ has a [https://arbital.com/p/-fixed_point](https://arbital.com/p/-fixed_point) (i.e. $x$ such that $f(x) = x$).

Let $f: A \to B$ and $g: B \to A$ be injective.

We are looking for a [partition](https://arbital.com/p/set_partition) $P \cup Q$ of $A$, and a partition $R \cup S$ of $B$, such that $f$ is injective from $P$ to $R$, and $g$ is injective from $S$ to $Q$.
(Then we can just define our bijection $A \to B$ by "do $f$ on $P$, and do $g^{-1}$ on $Q$".)

Now, the function $P \mapsto A \setminus g(B \setminus f(P))$ is order-preserving from the [https://arbital.com/p/-power_set](https://arbital.com/p/-power_set) $\mathcal{P}(A)$ to $\mathcal{P}(A)$ (ordered by inclusion), because there is an even number of complements.

But $\mathcal{P}(A)$ is complete as a poset ([proof](https://arbital.com/p/power_set_poset_is_complete)), so by Knaster-Tarski there is a set $P$ such that $P = A \setminus g(B \setminus f(P))$.

This yields our partition as required.

Summary: The Cantor-Schröder-Bernstein theorem tells us that if one [set](https://arbital.com/p/3jz) is [smaller-than-or-equal-to](https://arbital.com/p/4w5) another, and the other is smaller-than-or-equal-to the one, then they are the same size. That is, "comparison of set sizes" behaves itself, analogously to the fact in the [natural numbers](https://arbital.com/p/45h) that it can't be the case that both $1 < 2$ and $2<1$.


Well-defined

"Well-defined" is a slightly fuzzy word in mathematics.
Broadly, an object is said to be "well-defined" if it has been given a definition that is completely unambiguous, can be executed without regard to any arbitrary choices the mathematician might make, or generally is crisply defined.

(The [Wikipedia page](https://en.wikipedia.org/wiki/Well-defined) on well-definedness contains many examples for those who are more comfortable with mathematical notation.)

# Specific instances

## Functions
One of the most common uses of the phrase "well-defined" is when talking about [functions](https://arbital.com/p/3jy).
A function is **well-defined** if it really is a bona fide function.
This usually manifests itself as the following:

> Whenever $x=y$, we have $f(x) = f(y)$: that is, the output of the function doesn't depend on how we specify the input to the function, only on the input itself.

This property is often pretty easy to check.
For instance, the function from [$\mathbb{N}$](https://arbital.com/p/45h) to itself given by $n \mapsto n+1$ is "obviously" well-defined: it's trivially obvious that if $n=m$ then $f(n) = f(m)$.

However, sometimes it is not so easy.
The function $\mathbb{N} \to \mathbb{N}$ given by "take the number of prime factors" is not obviously well-defined, because it could in principle be the case that some number $n$ is equal to both $p_1 p_2 p_3$ and $q_1 q_2$ for some primes $p_1, p_2, p_3, q_1, q_2$; then our putative function might plausibly attempt to output either $3$ or $2$ on the same natural number input $n$, so the function would not be well-defined.
(It turns out that there is a non-trivial theorem, the [Fundamental Theorem of Arithmetic](https://arbital.com/p/5rh), guaranteeing that this function *is* in fact well-defined.)

Well-definedness in this context comes up very often when we are attempting to take a [quotient](https://arbital.com/p/quotient_by_equivalence_relation).
The fact that we can take the quotient of a [https://arbital.com/p/-3jz](https://arbital.com/p/-3jz) $X$ by an [https://arbital.com/p/-53y](https://arbital.com/p/-53y) $\sim$ is tantamount to saying:

> The function $X \to \frac{X}{\sim}$, given by $x \mapsto [https://arbital.com/p/x](https://arbital.com/p/x)$ the equivalence class of $X$, is well-defined.

---

Another, different, way a function could fail to be well-defined is if we tried to take the function $\mathbb{N} \to \mathbb{N}$ given by $n \mapsto n-5$.
This function is unambiguous, but it's not well-defined, because on the input $2$ it tries to output $-3$, which is not in the specified [codomain](https://arbital.com/p/3lg).

Summary: "Well-defined" is a slightly fuzzy word in mathematics. An object is said to be "well-defined" if it has been given a definition that is completely unambiguous, can be executed without regard to any arbitrary choices the mathematician might make, or generally is crisply defined.


Needs splitting by mastery

Readers who come to Arbital pages with different levels of mathematical background require different pages to explain the same concept. Sometimes a page is written in a way that seems to cater for multiple audiences (e.g. having a careful wordy explanation designed for people with little background, then throwing out formulas and proofs that could only be followed by someone with much more background). In these cases, it's often best to split the page into multiple [lenses](https://arbital.com/p/17b), designed for different [math level](https://arbital.com/p/52x) audiences.


Proof of Rice's theorem

Recall the formal statement of [Rice's theorem](https://arbital.com/p/5mv):

> We will use the notation $[https://arbital.com/p/n](https://arbital.com/p/n)$ for the $n$th [Turing machine](https://arbital.com/p/5pd) under some fixed [numbering system](https://arbital.com/p/description_number).
Each such machine induces a [https://arbital.com/p/-3jy](https://arbital.com/p/-3jy), which we will also write as $[https://arbital.com/p/n](https://arbital.com/p/n)$ where this is unambiguous due to context; then it makes sense to write $[n](m)$ for the value that machine $[https://arbital.com/p/n](https://arbital.com/p/n)$ outputs when it is run on input $m$.

> Let $A$ be a non-empty, proper %%note:That is, it is not the entire set.%% subset of $\{ \mathrm{Graph}(n) : n \in \mathbb{N} \}$, where $\mathrm{Graph}(n)$ is the [graph](https://arbital.com/p/graph_of_a_function) of the [https://arbital.com/p/-5p2](https://arbital.com/p/-5p2) computed by $[https://arbital.com/p/n](https://arbital.com/p/n)$, the $n$th Turing machine.
Then there is no Turing machine $[https://arbital.com/p/r](https://arbital.com/p/r)$ such that:

> - $[r](i)$ is $1$ if $\mathrm{Graph}(i) \in A$
> - $[r](i)$ is $0$ if $\mathrm{Graph}(i) \not \in A$.

We give a proof that is (very nearly) constructive: one which (if we could be bothered to work it all through) gives us an explicit example %%note:Well, very nearly; see the next note.%% of a [Turing machine](https://arbital.com/p/5pd) whose "am-I-in-$A$" nature cannot be determined by a Turing machine.
%%note:It's only "very nearly" constructive. It would be *actually* constructive if we knew in advance a specific example of a program whose function is in $A$, and a program whose function is in $B$. The proof here assumes the existence of a program of each type, but ironically the theorem itself guarantees that there is no fully-general way to *find* such programs.%%

We will present an intermediate lemma which does all the heavy lifting; this makes the actual reasoning rather unclear but very succinct, so we will also include an extensive worked example of what this lemma does for us.

# Fixed point theorem

The intermediate lemma is a certain fixed-point theorem.

> Let $h: \mathbb{N} \to \mathbb{N}$ be [total](https://arbital.com/p/total_function) computable: that is, it halts on every input.
Then there is $n \in \mathbb{N}$ such that $\mathrm{Graph}(n) = \mathrm{Graph}(h(n))$. %%note:And, moreover, we can actually *find* such an $n$.%%

That is, the "underlying function" of $n$ - the partial function computed by $[https://arbital.com/p/n](https://arbital.com/p/n)$ - has the same output, at every point, as the function computed by $[https://arbital.com/p/h](https://arbital.com/p/h)$.
If we view $h$ as a way of manipulating a program (as specified by its [https://arbital.com/p/-description_number](https://arbital.com/p/-description_number)), then this fixed-point theorem states that we can find a program whose underlying function is not changed at all by $h$.

The proof of this lemma is quite simple once the magic steps have been discovered, but it is devilishly difficult to intuit, because it involves two rather strange and confusing recursions and some self-reference.

Recall the [$s_{mn}$ theorem](https://arbital.com/p/translation_lemma), which states that there is a total computable function $S$ of two variables $m, n$ such that for every $e \in \mathbb{N}$, we have $[e](m, n) = [S(e,m)](n)$: that is, there is a total computable way $S$ of [https://arbital.com/p/-50p](https://arbital.com/p/-50p) computable functions.
(Strictly speaking, our Turing machines only take one argument. Therefore we should use a computable pairing scheme such as [Cantor's pairing function](https://arbital.com/p/cantor_pairing_function), so that actually $[e](m,n)$ should be interpreted as $[e](\mathrm{pair}) (m, n))$.)

Then the function which takes the pair $(e, x)$ and outputs the value of $[ h(S(e,e)) ](x)$ is computable, so it has a description number $a$, say.
%%note:This is the first strange part: we are treating $e$ both as a description number, and as an input to $[https://arbital.com/p/e](https://arbital.com/p/e)$, when we consider $S(e,e)$.%%

Now we claim that $S(a, a)$ is the $n$ we seek. %%note:This is the second strange part, for the same reason as $S(e,e)$ was the first; but this one is even worse, because the definition of $a$ already involves a weird recursion and we've just added another one on top.%%
Indeed, for any $x$, $[n](x) = [S(a,a)](x)$ by definition of $n$; this is $[a](a, x)$ by the $s_{mn}$ theorem; this is $[h(S(a,a))](x)$ by definition of $[https://arbital.com/p/a](https://arbital.com/p/a)$; and that is $[h(n)](x)$ by definition of $n$.

Therefore $[n](x) = [h(n)](x)$, so we have found our fixed point.

%%hidden(Worked example):

Suppose our description numbering scheme is just "expand $n$ as a number in base $128$, and interpret the result as an [ASCII](https://en.wikipedia.org/wiki/ASCII) %%note:This is a standard, agreed-upon method of turning a number between $0$ and $128$ into a character.%% string; then interpret that string as [Python](https://en.wikipedia.org/wiki/Python_) (programming_language)) code".

Then our function $h$, whatever it may be, can be viewed just as transforming Python code.

Suppose $h$ does nothing more than insert the following line of code as the second line of its input:

	x = 0

So, for instance, it takes the string

	x = 1
	print(x)

and returns

	x = 1
	x = 0
	print(x)

thereby changing the function computed from "return the constant $1$" to "return the constant $0$", in this case.
Note that many other functions will not change at all: for example, those which don't contain a variable $x$ in the first place will be unchanged, because all the modification does is add in an initialisation of a variable which will never subsequently be used.

The fixed-point theorem guarantees that there is indeed a Python program which will not change at all under this modification (though in this case it's very obvious).
In fact the theorem *constructs* such a program; can we work out what it is?

First of all, $S(m, n)$ can be implemented as follows.
We will take our Python code to be written so that their input is given in the variable `r1`, so $[e](5)$ is simply the Python code represented by $e$ but where the code-variable `r1` is initialised to $5$ first; that is, it can be found by prepending the line `r1 = 5` to the code represented by $e$.
Then we will assume that Python comes with a function `eval` (corresponding to $S$) which takes as its input a string %%note:The string is standing in place of $m$, but we have just skipped the intermediate step of "unpack the integer into a string" and gone straight to assuming it is a string.%% and another argument with which `eval` initialises the variable `x` before running the string as a Python program in a separate instance of Python:

	eval("print(r1)", 5)  # does nothing other than print the number 5
	eval("print(y)", 5)  # throws an error because `y` is not defined when it comes to printing it
	eval("print(6)", 5)  # prints 6, ignoring the fact that the variable `r1` is equal to `5` in the sub-instance

Remember, our proof of the fixed point theorem says that the program we want has code $S(a, a)$, where $a$ takes a pair $(e, x)$ as input, and outputs $[h(S(e,e))](x)$.
What is $a$ specifically here?
Well, on the one hand we're viewing it as a string of code (because it comes as the first argument to $S$), and on the other we're viewing it as an integer (because it also comes as the second argument to $S$).

As code, `a` is the following string, where `h` is to be replaced by whatever we've already decided $h$ is:

	eval("r1 = e; h(eval(r1, str_as_int(r1)))", x)

We are assuming the existence of a function `str_as_int` which takes an ASCII string and returns the integer whose places in base 128 are the ASCII for each character of the string in turn.

For example, we have $h$ inserting the line `x = 0` as the second line, so our `a` is:

	eval("r1 = e; x = 0; eval(r1, str_as_int(r1))", x)

As a number, `a` is just the ASCII for this, interpreted in base 128 (i.e. a certain number which in this case happens to have 106 digits, which is why we don't give it here).

The claim of the fixed-point theorem, then, is that the following program is unchanged by $h$:

	eval("eval(\"r1 = e; x = 0; eval(r1, str_as_int(r1))\", x)", str_to_int("eval(\"r1 = e; x = 0; eval(r1, str_as_int(r1))\", x)"))

You may recognise this as a [quining](https://arbital.com/p/322) construction.
%%

# Deducing Rice's theorem from the fixed point theorem

Finally, Rice's theorem follows quickly: suppose we could decide in general whether $\mathrm{Graph}(n) \in A$ or not, and label by $\iota$ the computable function which decides this (that is, whose value is $1$ if $\mathrm{Graph}(n) \in A$, and $0$ otherwise).

Since $A$ is nonempty and proper, there are natural numbers $a$ and $b$ such that $\mathrm{Graph}(a) \in A$ but $\mathrm{Graph}(b) \not \in A$.
Define the computable function $g$ which takes $n$ and outputs $a$ if $\iota(n) = 0$, and $b$ otherwise.
(That is, it flips its input: if its input had the property of $A$, the function $g$ outputs $b$ whose graph is not in $A$, and vice versa.
Informally, it is the program-transformer that reads in a program, determines whether the program computes a function in $A$ or not, and transforms the program into a specific canonical example of something which has the *opposite* $A$-ness status.)

By the fixed-point theorem, we can find $n$ such that $\mathrm{Graph}(n) = \mathrm{Graph}(g(n))$.

But now we can ask whether $\mathrm{Graph}(n)$ is in $A$ (and therefore whether $\mathrm{Graph}(g(n))$ is in $A$).

- If it is in $A$, then $g(n) = b$ and so $\mathrm{Graph}(g(n)) = \mathrm{Graph}(b)$ which is not in $A$.
- If it is not in $A$, then $g(n) = a$ and so $\mathrm{Graph}(g(n)) = \mathrm{Graph}(a)$ is in $A$.

We have obtained [contradictions](https://arbital.com/p/46z) in both cases (namely that $\mathrm{Graph}(g(n))$ is both in $A$ and not in $A$), so it must be the case that $\iota$ does not exist after all.

Summary: This lens proves [Rice's theorem](https://arbital.com/p/5mv) via a fixed-point theorem on computable functions.


Needs links

Some pages don't have many [greenlinks](https://arbital.com/p/17f), making them less useful than they could be.


Algorithmic complexity

Algorithmic complexity is a formal measure of the minimum amount of information required to specify some message, binary string, computer program, classification rule, etcetera.  The algorithmic complexity or Kolmogorov complexity of a message is the number of 1s and 0s required to specify a Turing machine that reproduces the message.

(The relevant Wikipedia article is filed under [Kolmogorov complexity](http://en.wikipedia.org/wiki/Kolmogorov_complexity).  Not to be confused with "[computational complexity](https://arbital.com/p/49w)", which isn't the same thing at all.)

A string of a million 1s has around as much K-complexity as the number 1,000,000, since getting a Turing machine to print out exactly a million 1s and then stop, is mostly a matter of encoding the number 1,000,000.  The number 1,000,000 can itself potentially be compressed further, since it's an unusually simple number of that magnitude: it's 10 to the 6th power, so if we already have a concept of 'exponentiation' or can encode it simply, we just need to encode the numbers 10 and 6, which are quite small.

When we say that a message has high Kolmogorov complexity, we mean that it *can't be compressed beyond a certain point* (unless the 'compression algorithm' is itself large and contains much of the key information baked in).  Things have high Kolmogorov complexity when they're made up of many independent facts that can't be predicted from knowing the previous facts.

Shakespeare's _Romeo and Juliet_ will compress by a lot using simple algorithms, because there are many words used more than once, and some words are much more frequent than others.  But we are exceedingly unlikely to find, anywhere in the first trillion Turing machines, any Turing machine that prints out the exact text of this play.  2^40 is greater than a trillion, so if we consider the set of all 40-bit binary strings, it's clear we can't print out *all* of them exactly using the first trillion Turing machines.  Finding a 40-bit Turing machine that printed out the exact text of _Romeo and Juliet_ would be vastly improbable.

On the other hand, it wouldn't be particularly surprising to find a small Turing machine that printed out $3\uparrow\uparrow\uparrow3$ 1s and then stopped, because the algorithm for this enormous number seems simple, and easy to encode as a computer program or Turing machine.

The algorithmic complexity of a system shouldn't be confused with the total number of visible, complicated-looking details.  The [Mandelbrot set](https://en.wikipedia.org/wiki/Mandelbrot_set) looks very complicated visually - you can keep zooming in using more and more detail - but there's a very simple rule that generates it, so we say the algorithmic complexity is very low.

As a corollary, a piece of a big-looking object can easily have more Kolmogorov complexity than the whole.  If you zoom far down into the Mandelbrot set and isolate a particular piece of the fractal, the information of that image now includes both the Mandelbrot-generating rule and also the exact location of that particular piece.

Similarly, the Earth is much more algorithmically complex than the laws of physics, and if there's a multiverse that developed deterministically out of the laws of physics, the Earth would be much more complex than that multiverse.  To print out the whole multiverse, you'd only need to start from the laws of physics and work forward; to print out *Earth in particular* you'd need a huge number of additional bits to locate Earth *inside* the multiverse.

Or more simply, we can observe that a program that prints out all possible books in order, is much simpler than a program that prints out only _Romeo and Juliet_.  To put it another way, Borge's "Library of Babel" containing every possible book has far lower algorithmic complexity than an Earth library containing only some books.  The moral is that the amount of visible stuff and its seeming surface complexity should not be confused with the notion of algorithmic complexity or theoretical compressibility.

Eliezer Yudkowsky
Alexei Andreev
Jaime Sevilla Molina


Image requested

An editor has requested an image for this page, described in a \.


Euclidean domains are principal ideal domains

summary(Technical): Let $R$ be a [https://arbital.com/p/euclidean_domain](https://arbital.com/p/euclidean_domain). Then $R$ is a [https://arbital.com/p/-5r5](https://arbital.com/p/-5r5).

A common theme in [ring theory](https://arbital.com/p/3gq) is the idea that we identify a property of the [integers](https://arbital.com/p/48l), and work out what that property means in a more general setting.
The idea of the [https://arbital.com/p/euclidean_domain](https://arbital.com/p/euclidean_domain) captures the fact that in $\mathbb{Z}$, we may perform the [https://arbital.com/p/-division_algorithm](https://arbital.com/p/-division_algorithm) (which can then be used to work out [greatest common divisors](https://arbital.com/p/5mw) and other such nice things from $\mathbb{Z}$).
Here, we will prove that this simple property actually imposes a lot of structure on a ring: it forces the ring to be a [https://arbital.com/p/-5r5](https://arbital.com/p/-5r5), so that every [ideal](https://arbital.com/p/ideal_ring_theory) has just one generator.

In turn, this forces the ring to have [unique factorisation](https://arbital.com/p/5vk) ([proof](https://arbital.com/p/pid_implies_ufd)), so in some sense the [Fundamental Theorem of Arithmetic](https://arbital.com/p/5rh) (i.e. the statement that $\mathbb{Z}$ is a unique factorisation domain) is true entirely because the division algorithm works in $\mathbb{Z}$.

This result is essentially why we care about Euclidean domains: because if we know a Euclidean function for an integral domain, we have a very easy way of recognising that the ring is a principal ideal domain.

# Formal statement

Let $R$ be a [https://arbital.com/p/euclidean_domain](https://arbital.com/p/euclidean_domain).
Then $R$ is a [https://arbital.com/p/-5r5](https://arbital.com/p/-5r5).

# Proof

This proof essentially mirrors the first proof one might find in the concrete case of the integers, if one sat down to discover an integer-specific proof; but we cast it into slightly different language using an equivalent definition of "ideal", because it is a bit cleaner that way.
It is a very useful exercise to work through the proof, using $\mathbb{Z}$ instead of the general ring $R$ and using "size" %%note:That is, if $n > 0$ then the size is $n$; if $n < 0$ then the size is $-n$. We just throw away the sign.%% as the Euclidean function.

Let $R$ be a Euclidean domain, and say $\phi: \mathbb{R} \setminus \{ 0 \} \to \mathbb{N}^{\geq 0}$ is a Euclidean function.
That is,

- if $a$ divides $b$ then $\phi(a) \leq \phi(b)$;
- for every $a$, and every $b$ not dividing $a$, we can find $q$ and $r$ such that $a = qb+r$ and $\phi(r) < \phi(b)$.

We need to show that every [ideal](https://arbital.com/p/ideal_ring_theory) is principal, so take an ideal $I \subseteq R$.
We'll view $I$ as the [kernel](https://arbital.com/p/5r6) of a [homomorphism](https://arbital.com/p/ring_homomorphism) $\alpha: R \to S$; recall that this is the proper way to think of ideals. ([Proof of the equivalence.](https://arbital.com/p/5r9))
Then we need to show that there is some $r \in R$ such that $\alpha(x) = 0$ if and only if $x$ is a multiple of $r$.

If $\alpha$ only sends $0$ to $0$ (that is, everything else doesn't get sent to $0$), then we're immediately done: just let $r = 0$.

Otherwise, $\alpha$ sends something nonzero to $0$; choose $r$ to be nonzero with minimal $\phi$.
We claim that this $r$ works.

Indeed, let $x$ be a multiple of $r$, so we can write it as $ar$, say.
Then $\alpha(ar) = \alpha(a) \alpha(r) = \alpha(a) \times 0 = 0$.
Therefore multiples of $r$ are sent by $\alpha$ to $0$.

Conversely, if $x$ is *not* a multiple of $r$, then we can write $x = ar+b$ where $\phi(b) < \phi(r)$ and $b$ is nonzero. %%note: The fact that we can do this is part of the definition of the Euclidean function $\phi$.%%
Then $\alpha(x) = \alpha(ar)+\alpha(b)$; we already have $\alpha(r) = 0$, so $\alpha(x) = \alpha(b)$.
But $b$ has a smaller $\phi$-value than $r$ does, and we picked $r$ to have the *smallest* $\phi$-value among everything that $\alpha$ sent to $0$; so $\alpha(b)$ cannot be $0$, and hence nor can $\alpha(x)$.

So we have shown that $\alpha(x) = 0$ if and only if $x$ is a multiple of $r$, as required.

# The converse is false

There do exist principal ideal domains which are not Euclidean domains: $\mathbb{Z}[](https://arbital.com/p/\frac{1}{2})$ is an example. ([Proof.](http://www.maths.qmul.ac.uk/~raw/MTH5100/PIDnotED.pdf))

Summary: The [https://arbital.com/p/-division_algorithm](https://arbital.com/p/-division_algorithm) is a fundamental property of the [integers](https://arbital.com/p/48l), and it turns out that almost all of the nicest properties of the integers stem from the division algorithm. All [rings](https://arbital.com/p/3gq) which have the division algorithm (that is, [Euclidean domains](https://arbital.com/p/euclidean_domain)) are [principal ideal domains](https://arbital.com/p/5r5): they have the property that every [ideal](https://arbital.com/p/ideal_ring_theory) has just one generator.


Unique factorisation domain

summary: A [ring](https://arbital.com/p/3gq) $R$ is a *unique factorisation domain* if an analog of the [https://arbital.com/p/5rh](https://arbital.com/p/5rh) holds in it. The condition is as follows: every nonzero element, which does not have a multiplicative inverse, must be expressible as a product of [irreducibles](https://arbital.com/p/5m1), and the expression must be unique if we do not care about ordering or about multiplying by elements which have multiplicative inverses.

[Ring theory](https://arbital.com/p/3gq) is the art of extracting properties from the [integers](https://arbital.com/p/48l) and working out how they interact with each other.
From this point of view, a *unique factorisation domain* is a ring in which the integers' [https://arbital.com/p/5rh](https://arbital.com/p/5rh) holds.

There have been various incorrect "proofs" of Fermat's Last Theorem throughout the ages; it turns out that if we assume the false "fact" that all subrings of [$\mathbb{C}$](https://arbital.com/p/4zw) are unique factorisation domains, then FLT is not particularly difficult to prove.
This is an example of where abstraction really is helpful: having a name for the concept of a UFD, and a few examples, makes it clear that it is not a trivial property and that it does need to be checked whenever we try and use it.

# Formal statement

Let $R$ be an [https://arbital.com/p/-5md](https://arbital.com/p/-5md).
Then $R$ is a *unique factorisation domain* if every nonzero non-[unit](https://arbital.com/p/5mg) element of $R$ may be expressed as a product of [irreducibles](https://arbital.com/p/5m1), and moreover this expression is unique up to reordering and multiplying by units.

# Why ignore units?

We must set things up so that we don't care about units in the factorisations we discover.
Indeed, if $u$ is a unit %%note:That is, it has a multiplicative inverse $u^{-1}$.%%, then $p \times q$ is always equal to $(p \times u) \times (q \times u^{-1})$, and this "looks like" a different factorisation into irreducibles.
($p \times u$ is irreducible if $p$ is irreducible and $u$ is a unit.)
The best we could possibly hope for is that the factorisation would be unique if we ignored multiplying by invertible elements, because those we may always forget about.

## Example

In $\mathbb{Z}$, the units are precisely $1$ and $-1$.
We have that $-10 = -1 \times 5 \times 2$ or $-5 \times 2$ or $5 \times -2$; we need these to be "the same" somehow.

The way we make them be "the same" is to insist that the $5$ and $-5$ are "the same" and the $2$ and $-2$ are "the same" (because they only differ by multiplication of the unit $-1$), and to note that $-1$ is not irreducible (because irreducibles are specifically defined to be non-unit) so $-1 \times 5 \times 2$ is not actually a factorisation into irreducibles.

That way, $-1 \times 5 \times 2$ is not a valid decomposition anyway, and $-5 \times 2$ is just the same as $5 \times -2$ because each of the irreducibles is the same up to multiplication by units.

# Examples

- Every [https://arbital.com/p/-5r5](https://arbital.com/p/-5r5) is a unique factorisation domain. ([Proof.](https://arbital.com/p/pid_implies_ufd)) This fact is not trivial! Therefore $\mathbb{Z}$ is a UFD, though we can also prove this directly; this is the [https://arbital.com/p/5rh](https://arbital.com/p/5rh).
- $\mathbb{Z}[https://arbital.com/p/-\sqrt{3}](https://arbital.com/p/-\sqrt{3})$ is *not* a UFD. Indeed, $4 = 2 \times 2$ but also $(1+\sqrt{-3})(1-\sqrt{-3})$; these are both decompositions into irreducible elements. (See the page on [irreducibles](https://arbital.com/p/5m1) for a proof that $2$ is irreducible; the same proof can be adapted to show that $1 \pm \sqrt{-3}$ are both irreducible.)

# Properties

- If it is hard to test for uniqueness up to reordering and multiplying by units, there is an easier but equivalent condition to check: an integral domain is a unique factorisation domain if and only if every element can be written (not necessarily uniquely) as a product of irreducibles, and all irreducibles are [prime](https://arbital.com/p/5m2). ([Proof.](https://arbital.com/p/alternative_condition_for_ufd))

Summary: An [https://arbital.com/p/-5md](https://arbital.com/p/-5md) $R$ is said to be a *unique factorisation domain* if every nonzero non-[unit](https://arbital.com/p/5mg) element of $R$ may be written as a product of [irreducibles](https://arbital.com/p/5m1), and moreover this product is unique up to reordering and multiplying by units.


Factorial

# Three objects in a line

How many ways are there to arrange three objects in a line?
(I'll use numbers $1,2,3$ to represent the objects; pretend I painted the numbers onto the respective objects.)
For example, $1,2,3$ is one way to arrange the three objects; $1,3,2$ is another; and so on.

To be completely concrete, let's say I have three same-sized cubes and I have three same-sized boxes to place them in; the boxes are arranged into one row and can't be moved (they're too heavy), but the cubes are made of balsa wood and can be moved freely.
The number $1$ is painted on one cube; $2$ on another; and $3$ on the third.
How many ways are there to arrange the cubes into the fixed boxes?

Have a think about this, then reveal the answer and a possible way of getting the answer.

%%hidden(Show solution):
The total number of ways is $6$.
The complete list of possible options is:

- $1,2,3$
- $1,3,2$
- $2,1,3$
- $2,3,1$
- $3,1,2$
- $3,2,1$

I've listed them in an order that hopefully makes it fairly easy to see that there are no more possibilities.
First I listed every possible way $1$ could come at the beginning; then every possible way $2$ could; then every possible way $3$ could.

If you got the answer $6$ through some *other* method, that's (probably) fine: there are many ways to think about this problem.
%%

How about arranging four objects in a line? (That is, four cubes into four fixed boxes.)

The total number of ways is $24$.
The complete list of possible options is:

- $1,2,3,4$
- $1,2,4,3$
- $1,3,2,4$
- $1,3,4,2$
- $1,4,2,3$
- $1,4,3,2$
- $2,1,3,4$

… I got bored.

How could we do this *without* listing all the possibilities?
I promise the answer really is $24$, but you should think about this for a bit before continuing.

# How to arrange four objects

There's an insight that makes everything much easier.

> Once we've placed a cube into the leftmost box, all we have left to do is fit the remaining three cubes into the remaining three boxes.

We've already seen above that there are $6$ ways to arrange three cubes among three boxes!

So the total number of ways of doing four cubes among four boxes is:

- $6$ ways where the leftmost box contains cube $1$ (and I actually listed all of those above before I got bored);
- $6$ ways where the leftmost box contains cube $2$;
- $6$ ways where the leftmost box contains cube $3$;
- $6$ ways where the leftmost box contains cube $4$.

That comes to $24$ in total.

# Interlude: Exercise

Can you work out how many ways there are to arrange *five* cubes into *five* fixed boxes?
Take a hint from how we did four boxes above.

%%hidden(Show solution):
There are $120$ ways to do this.
Remember, there are $24$ ways to arrange four cubes among four boxes.

Then to arrange five cubes among five boxes:

- $24$ ways where the leftmost box contains cube $1$
- $24$ ways where the leftmost box contains cube $2$
- $24$ ways where the leftmost box contains cube $3$
- $24$ ways where the leftmost box contains cube $4$
- $24$ ways where the leftmost box contains cube $5$

That comes to $120$ in total.
%%

# In general

OK, that was all well and good.
But if we didn't already know how to arrange four objects into four boxes, how could we jump straight to arranging five objects into five boxes?

Well, you might have noticed a pattern already.

- To arrange five boxes, we added the four-boxes number to itself five times; that is, we multiplied the four-boxes number by $5$.
- To arrange four boxes, we added the three-boxes number to itself four times; that is, we multiplied the three-boxes number by $4$.

Perhaps you can see that this will *always* work: to arrange $n$ boxes, we add the $n-1$-boxes number to itself $n$ times. That is, we multiply the $n-1$-boxes number by $n$.
Indeed, there are $n$ possible ways to fill the leftmost box %%note:We can do it with the number $1$, or the number $2$, or… or the number $n$; that's $n$ ways.%% and once we've done that, there are "the $n-1$-boxes number" ways to fill the remaining $n-1$ boxes.

But this still doesn't help us jump straight to how to arrange five objects into five boxes.
Here comes the clever bit.

Let's write $5!$ (with an exclamation mark) for the number that is "how many ways to arrange five objects into five boxes". %%note:We already know this number is actually $120$.%%
Similarly, $4!$ is "how many ways to arrange four objects into four boxes", and in general $n!$ is "how many ways to arrange $n$ objects into $n$ boxes".

Then the patterns we noted earlier become:

- $5! = 5 \times 4!$
- $4! = 4 \times 3!$

(Notice how much cleaner that is than "To arrange five boxes, we added the four-boxes number to itself five times; that is, we multiplied the four-boxes number by $5$". This is why mathematicians use notation: to make everything easier to say.)

And the general rule is: %%note: Being careful to put $n-1$ in brackets, because otherwise it looks like $n \times n - 1!$, which means $(n \times n)-1!$ according to the [https://arbital.com/p/-54s](https://arbital.com/p/-54s).%% $$n! = n \times (n-1)!$$

OK, we have

- $n! = n \times (n-1)!$, and
- $(n-1)! = (n-1) \times (n-2)!$, and
- $(n-2)! = (n-2) \times (n-3)!$, and so on.

So $$n! = n \times (n-1)! = n \times (n-1) \times (n-2)! = n \times (n-1) \times (n-2) \times (n-3)!$$
and so on.

If we just keep going, we'll eventually reach $$n \times (n-1) \times (n-2) \times \dots \times 5 \times 4 \times 3!$$
and we already know that $3! = 6$, which I'll write as $3 \times 2 \times 1$ for reasons which are about to become obvious.

So we have the following formula, which is how we define the **factorial**:

$$n! = n \times (n-1) \times \dots \times 4 \times 3 \times 2 \times 1$$

"$n!$" is read out loud as "$n$ factorial", and it means "the number of ways to arrange $n$ objects into any order".

# Edge cases

We've seen $3!$, but never $2!$ or $1!$.

- It's easy to see that there are two ways to arrange two objects into an order: $1,2$ or $2,1$.
So $2! = 2$.
- It's also easy (if a bit weird) to see that there is just one way of arranging one object into an order: $1$ is the only possible way. So $1! = 1$.
- How about arranging *no* objects into an order? This is even weirder, but the answer is $1$. There *is* a way to arrange no objects into an order: just don't put down any objects. This is something which you should just accept without thinking about it too hard, and it almost never crops up. Anyway, $0! = 1$.

Summary: The *factorial* of a number $n$ is how we describe "how many different ways we can arrange $n$ objects in a row".


Transcendental number

summary: A *transcendental* number $z$ is one such that there is no (nonzero) [https://arbital.com/p/-polynomial](https://arbital.com/p/-polynomial) function which outputs $0$ when given $z$ as input. $\frac{1}{2}$, $\sqrt{6}$, $i$ and $e^{i \pi/2}$ are not transcendental; $\pi$ and $e$ are both transcendental.

A [real](https://arbital.com/p/4bc) or [complex](https://arbital.com/p/4zw) number is said to be *transcendental* if it is not the root of any (nonzero) [https://arbital.com/p/-48l](https://arbital.com/p/-48l)-coefficient [https://arbital.com/p/-polynomial](https://arbital.com/p/-polynomial).
("Transcendental" means "not [algebraic](https://arbital.com/p/algebraic_number)".)

# Examples and non-examples

Many of the most interesting numbers are *not* transcendental.

- Every integer is *not* transcendental (i.e. is algebraic): the integer $n$ is the root of the integer-coefficient polynomial $x-n$.
- Every [rational](https://arbital.com/p/4zq) is algebraic: the rational $\frac{p}{q}$ is the root of the integer-coefficient polynomial $qx - p$.
- $\sqrt{2}$ is algebraic: it is a root of $x^2-2$.
- $i$ is algebraic: it is a root of $x^2+1$.
- $e^{i \pi/2}$ (or $\frac{\sqrt{2}}{2} + \frac{\sqrt{2}}{2}i$) is algebraic: it is a root of $x^4+1$.

However, $\pi$ and $e$ are both transcendental. (Both of these are difficult to prove.)

# Proof that there is a transcendental number

There is a very sneaky proof that there is some transcendental real number, though this proof doesn't give us an example.
In fact, the proof will tell us that "[almost all](https://arbital.com/p/almost_every)" real numbers are transcendental.
(The same proof can be used to demonstrate the existence of [irrational numbers](https://arbital.com/p/54z).)

It is a fairly easy fact that the *non*-transcendental numbers (that is, the algebraic numbers) form a [https://arbital.com/p/-countable](https://arbital.com/p/-countable) subset of the real numbers.
Indeed, the [Fundamental Theorem of Algebra](https://arbital.com/p/fundamental_theorem_of_algebra) states that every polynomial of degree $n$ has exactly $n$ complex roots (if we count them with [multiplicity](https://arbital.com/p/multiplicity), so that $x^2+2x+1$ has the "two" roots $x=-1$ and $x=-1$).
There are only countably many integer-coefficient polynomials , and each has only finitely many complex roots (and therefore only finitely many—possibly $0$—*real* roots), so there can only be countably many numbers which are roots of *any* integer-coefficient polynomial.

But there are uncountably many reals ([proof](https://arbital.com/p/reals_are_uncountable)), so there must be some real (indeed, uncountably many!) which is not algebraic.
That is, there are uncountably many transcendental numbers.

# Explicit construction of a transcendental number

Eric Bruylant
Chris Barnett
Patrick Stevens
Joe Zeng

Summary: A [real](https://arbital.com/p/4bc) or [complex](https://arbital.com/p/4zw) number $z$ is said to be *transcendental* if there is no (nonzero) [https://arbital.com/p/-48l](https://arbital.com/p/-48l)-coefficient [https://arbital.com/p/-polynomial](https://arbital.com/p/-polynomial) which has $z$ as a [root](https://arbital.com/p/root_of_polynomial).


Ordered field

An **ordered field** is an [https://arbital.com/p/-55j](https://arbital.com/p/-55j) with the additional property that [https://arbital.com/p/-division](https://arbital.com/p/-division) is possible, making it a [field](https://arbital.com/p/481).


Placeholder

This is an empty page created for a [parent](https://arbital.com/p/3n), [requisite](https://arbital.com/p/1ln), or [teaches](https://arbital.com/p/3jg) relationship. If you know about this topic and want to help others understand it, you're welcome to [fill in this gap](https://arbital.com/edit/) in [Arbital's knowledge network](https://arbital.com/p/1sm)!

Contrast:

* [https://arbital.com/p/72](https://arbital.com/p/72), for tiny pages containing only a paragraph or a couple of sentences of text.
* [https://arbital.com/p/5xq](https://arbital.com/p/5xq), for outlines of pages.

**[Quality scale](https://arbital.com/p/4yg)**

* [https://arbital.com/p/4ym](https://arbital.com/p/4ym)
* [https://arbital.com/p/4gs](https://arbital.com/p/4gs)
* [https://arbital.com/p/5xs](https://arbital.com/p/5xs)
* [https://arbital.com/p/5xq](https://arbital.com/p/5xq)
* [https://arbital.com/p/72](https://arbital.com/p/72)
* [https://arbital.com/p/3rk](https://arbital.com/p/3rk)
* [https://arbital.com/p/4y7](https://arbital.com/p/4y7)
* [https://arbital.com/p/4yd](https://arbital.com/p/4yd)
* [https://arbital.com/p/4yf](https://arbital.com/p/4yf)
* [https://arbital.com/p/4yl](https://arbital.com/p/4yl)


LaTeX


Mathematical object


Element


Proof technique


Turing machine: External resources

* [Wikipedia](https://en.wikipedia.org/wiki/Turing_machine)
* [Wolfram MathWorld](http://mathworld.wolfram.com/TuringMachine.html)
* [Stanford Encyclopedia of Philosophy](http://plato.stanford.edu/entries/turing-machine/)