Group presentation

[summary: A presentation $\langle X \mid R
angle$ of a [3gd group] is, informally, a way of specifying the group by a set $X$ of *generators* together with a set $R$ of *relators*.
Every element of the group is some product of generators, and the relators tell us when a product is trivial.]

[summary(Technical): A presentation $\langle X \mid R
angle$ of a [3gd group] $G$ is a set $X$ of *generators* and a set $R$ of *relators* which are words on $X \cup X^{-1}$, such that $G \cong F(X) / \llangle R
rangle^{F(X)}$ the [-normal_closure] of $\llangle R
rangle$ with respect to the [-5kg] $F(X)$. ]

A presentation $\langle X \mid R
angle$ of a group $G$ is an object that can be viewed in two ways:

 - a way of making $G$ as a [4tq quotient] of the [-5kg] on some set $X$
 - a set $X$ of *generators* (from which we form the set $X^{-1}$ of formal inverses to $X$%%note:For example, if $X = \{ a, b \}$ then $X^{-1}$ is a set of new symbols which we may as well write $\{ a^{-1}, b^{-1} \}$. %%), and a set $R$ of *relators* (which must be [5jc freely reduced words] on $X \cup X^{-1}$), such that every element of $G$ may be written as a product of the generators and such that by combining elements of $R$ we can obtain every possible way of expressing the identity element of $G$ as a product of elements of $X$.

Every group $G$ has a presentation with $G$ as the set of generators, and the set of relators is the set containing every trivial word.
Of course, this presentation is in general not unique: we may, for instance, add a new generator $t$ and the relator $t$ to any presentation to obtain an [49x isomorphic] presentation.

The above presentation corresponds to taking the quotient of the free group $F(G)$ on $G$ by the homomorphism $\phi: F(G) 	o G$ which sends a word $(a_1, a_2, \dots, a_n)$ to the product $a_1 a_2 \dots a_n$.
This is an instance of the more widely-useful fact that every group is a [4tq quotient] of a [-5kg] ([5jb proof]).

# Examples

- The [-47y] $C_2$ on two elements has a presentation $\langle x \mid x^2
angle$. That is, it has just one generator, $x$, and the relator $x^2$ tells us that $x^2$ is the [54p identity] $e$.
Notice that $\langle x \mid x^4
angle$ would also satisfy the description that "there is one generator, and $x^4$ is the identity". However, the group corresponding to *this* presentation contains four elements, not two, so it is not $C_2$. This demonstrates the fact that if we have a presentation $\langle X \mid R
angle$, and a group can be written in such a way that all the relators hold in the group, and the group can be generated by the elements of $X$, that still doesn't mean the presentation describes the group; it could be that extra relations hold in the group that aren't listed in $R$. (In this case, for example, $x^2 = e$ is not listed in $\langle x \mid x^4
angle$.)
- The presentation $\langle x, y \mid xyx^{-1}y^{-1}
angle$ describes a group with two generators, such that the only nontrivial relation is $xyx^{-1}y^{-1} = e$ (and anything that can be built up from that). That relation may be written as $xy=yx$: that is, $x$ and $y$ [3jb commute]. This tells us that the group is [3h2 abelian], since every generator commutes with every other generator. In fact, this group's elements are just words $x^n y^m$ for some integers $n, m$; this follows because, for instance, $xyx = xxy = x^2y$, and in general we can pull all the instances of the letter $x$ (and $x^{-1}$) out to the front of the word. Therefore we can write an element of this group as $(m, n)$ where $m, n$ are integers; hence the group is just $\mathbb{Z}^2$ with pointwise addition as its operation.
- The presentation $\langle x, y \mid x^2, y
angle$ is just $C_2$ again. Indeed, we have a relator telling us that $y$ is equal to the identity, so we might as well just omit it from the generating set (because it doesn't add anything new to any word in which it appears).
- The presentation $\langle a, b \mid aba^{-1}b^{-2}, bab^{-1}a^{-2}
angle$ is a longwinded way to define the trivial group (the group with one element). To prove this, it is enough to show that each generator represents the identity, because then every word on the generators has been made up from the identity element so is itself the identity. We have access to the facts that $ab = b^2 a$ and that $ba = a^2 b$ in this group (because, for example, $aba^{-1} b^{-2} = e$). The rest of the proof is an exercise.

%%hidden(Show solution):
We have $ab = b^2 a$ from the first relator; that is $b ba$.
But $ba = a^2 b$ is the second relator, so that is $b a^2 b$; hence $ab = b a^2 b$ and so $a = b a^2$ by cancelling the rightmost $b$.
Then by cancelling the rightmost $a$, we obtain $e = ba$, and hence $a = b^{-1}$.

But now by the first relator, $ab = b^2 a = b b a$; using that both $ab$ and $ba$ are the identity, this tells us that $e = b$; so $b$ is trivial.

Now $a = b^{-1}$ and so $a$ is trivial too.
%%

[todo: finite presentation/generation]
[todo: direct products]
[todo: semidirect products]


Every group is a quotient of a free group

Given a [3gd group] $G$, there is a [-free_group] $F(X)$ on some set $X$, such that $G$ is [49x isomorphic] to some [4tq quotient] of $F(X)$.

This is an instance of a much more general phenomenon: for a general [monad_category_theory monad] $T: \mathcal{C} 	o \mathcal{C}$ where $\mathcal{C}$ is a category, if $(A, lpha)$ is an [eilenberg_moore_category algebra] over $T$, then $lpha: TA 	o A$ is a [coequaliser_category_theory coequaliser]. ([algebras_are_coequalisers Proof.])

# Proof
Let $F(G)$ be the free group on the elements of $G$, in a slight abuse of notation where we use $G$ interchangeably with its [-3gz].
Define the [47t homomorphism] $	heta: F(G) 	o G$ by "multiplying out a word": taking the word $(a_1, a_2, \dots, a_n)$ to the product $a_1 a_2 \dots a_n$.

This is indeed a group homomorphism, because the group operation in $F(G)$ is concatenation and the group operation in $G$ is multiplication: clearly if $w_1 = (a_1, \dots, a_m)$, $w_2 = (b_1, \dots, b_n)$ are words, then $$	heta(w_1 w_2) = 	heta(a_1, \dots, a_m, b_1, \dots, b_m) = a_1 \dots a_m b_1 \dots b_m = 	heta(w_1) 	heta(w_2)$$

This immediately expresses $G$ as a quotient of $F(G)$, since [4h7 kernels of homomorphisms are normal subgroups].


Freely reduced word

[todo: make Free Group a parent of this]

[todo: make the summary a bit better]
[summary: A "word" over a set $X$ is a finite ordered list of elements from $X$ and $X^{-1}$ (where $X^{-1}$ is the set of formal inverses of the elements of $X$), as if we were treating the elements of $X$ and $X^{-1}$ as letters of an alphabet. A "freely reduced" word over $X$ is one which doesn't contain any consecutive cancelling letters such as $x x^{-1}$.]

Given a [3jz set] $X$, we can make a new set $X^{-1}$ consisting of "formal inverses" of elements of $X$.
That is, we create a set of new symbols, one for each element of $X$, which we denote $x^{-1}$; so $$X^{-1} = \{ x^{-1} \mid x \in X \}$$

By this stage, we have not given any kind of meaning to these new symbols.
Though we have named them suggestively as $x^{-1}$ and called them "inverses", they are at this point just objects.

Now, we apply meaning to them, giving them the flavour of group inverses, by taking the [set_union union] $X \cup X^{-1}$ and making finite "words" out of this combined "alphabet".

A finite word over $X \cup X^{-1}$ consists of a list of symbols from $X \cup X^{-1}$.
For example, if $X = \{ 1, 2 \}$ %%note:Though in general $X$ need not be a set of numbers.%%, then some words are:

- The empty word, which we commonly denote $arepsilon$
- $(1)$
- $(2)$
- $(2^{-1})$
- $(1, 2^{-1}, 2, 1, 1, 1, 2^{-1}, 1^{-1}, 1^{-1})$

For brevity, we usually write a word by just concatenating the "letters" from which it is made:

- The empty word, which we commonly denote $arepsilon$
- $1$
- $2$
- $2^{-1}$
- $1 2^{-1} 2 1 1 1 2^{-1} 1^{-1} 1^{-1}$

For even more brevity, we can group together successive instances of the same letter.
This means we could also write the last word as $1 2^{-1} 2 1^3 2^{-1} 1^{-2}$.

Now we come to the definition of a **freely reduced** word: it is a word which has no subsequence $r r^{-1}$ or $r^{-1} r$ for any $r \in X$.

# Example

If $X = \{ a, b, c \}$, then we might write $X^{-1}$ as $\{ a^{-1}, b^{-1}, c^{-1} \}$ (or, indeed, as $\{ x, y, z \}$, because there's no meaning inherent in the $a^{-1}$ symbol so we might as well write it as $x$).

Then $X \cup X^{-1} = \{ a,b,c, a^{-1}, b^{-1}, c^{-1} \}$, and some examples of words over $X \cup X^{-1}$ are:

- The empty word, which we commonly denote $arepsilon$
- $a$
- $aaaa$
- $b$
- $b^{-1}$
- $ab$
- $ab^{-1}cbb^{-1}c^{-1}$
- $aa^{-1}aa^{-1}$

Of these, all except the last two are freely reduced.
However, $ab^{-1}cbb^{-1}c^{-1}$ contains the substring $bb^{-1}$, so it is not freely reduced; and $aa^{-1}aa^{-1}$ is not freely reduced (there are several ways to see this: it contains $aa^{-1}$ twice and $a^{-1} a$ once).

%%hidden(Alternative, more opaque, treatment which might help with one aspect):
This chunk is designed to get you familiar with the idea that the symbols $a^{-1}$, $b^{-1}$ and so on in $X^{-1}$ don't have any inherent meaning.

If we had (rather perversely) gone with $\{ x, y, z \}$ as the corresponding "inverses" to $\{ a, b, c \}$ (in that order), rather than $\{ a^{-1}, b^{-1}, c^{-1} \}$ as our "inverses" %%note:Which you should never do. It just makes things harder to read.%%, then the above words would look like:

- The empty word, which we commonly denote $arepsilon$
- $a$
- $aaaa$, which we might also write as $a^4$
- $b$
- $y$
- $ab$
- $aycbyz$
- $axax$

For the same reasons, all but the last two would be freely reduced.
However, $aycbyz$ contains the substring $by$ so it is not freely reduced; and $axax$ is not freely reduced (there are several ways to see this: it contains $ax$ twice and $xa$ once).
%%

# Why are we interested in this?

We can use the freely reduced words to construct the [-5kg] on a given set $X$; this group has as its elements the freely reduced words over $X \cup X^{-1}$, and as its group operation "concatenation followed by free reduction" (that is, removal of pairs $r r^{-1}$ and $r^{-1} r$). %%note:We make this construction properly rigorous, and check that it is indeed a group, on the [5kg] page.%%
The notion of "freely reduced" basically tells us that $r r^{-1}$ is the identity for every letter $r \in X$, as is $r^{-1} r$; this cancellation of inverses is a property we very much want out of a group.

The free group is (in a certain well-defined sense from [-4c7]%%note:See [free_group_functor_is_left_adjoint_to_forgetful] for the rather advanced reason why.%%) the purest way of making a group containing the elements $X$, but to make it, we need to throw in inverses for every element of $X$, and then make sure the inverses play nicely with the original elements (which we do by free reduction).
That is why we need "freely-reducedness".


Division of rational numbers (Math 0)

[summary: Division captures the idea of "sharing" apples between people, and it is the core motivating idea of the rational numbers.]

So far in our study of the [514 arithmetic] of [4zq rational numbers], we've had [55m addition] ("putting apples and chunks of apples side by side and counting what you've got"), [56x subtraction] ("the same, but you're allowed anti-apples too"), and [59s multiplication] ("make a rational number, but instead of starting from $1$ apple, start from some other number").

**Division** is what really sets the rational numbers apart from the [53r integers], and it is the mathematician's answer to the question "if I have some apples, how do I share them among my friends?".

# What's wrong with the integers?

If you have an integer number of apples (that is, some number of apples and anti-apples - no chunks allowed, just whole apples and anti-apples), and you want to share them with friends, sometimes you'll get lucky.
If you have four apples, for instance, then you can share them out between yourself and one friend, giving each person two apples.

But sometimes (often, in fact) you'll get unlucky.
If you want to share four apples between yourself and two others, then you can give each person one apple, but there's this pesky single apple left over which you just can't share.

# What the rationals do for us

The trick, obvious to anyone who has ever eaten a cake, is to cut the leftover apple into three equally-sized pieces and give each person a piece.
Now we have shared out all four apples equally.

But in order to do so, we've left the world of the integers, and in getting out our knife, we started working in the rationals.
How much apple has everyone received, when we shared four apples among three people (that is, myself and two friends as recipients of apple)?
%%hidden(Show solution):
Everyone got $rac{4}{3}$.

Indeed, everyone got one whole apple; and then we chopped the remaining apple into three $rac{1}{3}$-chunks and gave everyone one chunk.
So everyone ended up with one apple and one $rac{1}{3}$-chunk.

By our instant addition rule %%note:If you've forgotten it, check out the [55m addition page] again; it came from working out a chunk size out of which we can make both the $rac{1}{3}$-chunk and the $1$-chunk.%%, $$1 + rac{1}{3} = rac{1}{1} + rac{1}{3} = rac{3 	imes 1 + 1 	imes 1}{3 	imes 1} = rac{3+1}{3} = rac{4}{3}$$

There's another way to see this, if (laudably!) you don't like just applying rules.
We could cut *every* apple into three pieces at the beginning, so we're left with four collections of three $rac{1}{3}$-sized chunks.
But now it's easy to share this among three people: just give everyone one of the $rac{1}{3}$-chunks from each apple.
We gave everyone four chunks in total, so this is $rac{4}{3}$.
%%

The rationals provide the natural answer to all "sharing" questions about apples.

We write "rational number $x$ divided by rational number $y$" as $rac{x}{y}$: that is, $x$ apples divided amongst $y$ people.
(We'll soon get to what it means to divide by a non-integer number of people; just roll with it for now.)
If space is a problem, we can write $a/n$ instead.
Notice that our familiar notation of "$rac{1}{m}$-sized chunks" is actually just $1$ apple divided amongst $m$ people: it's the result of dividing $1$ into $m$ equal chunks.
So the notation does make sense, and it's just an extension of the notation we've been using already.

# Division by a natural number

In general, $rac{a}{m}$ apples, divided amongst $n$ people, is obtained by the "other way" above.
Cut the $rac{a}{m}$ into $n$ pieces, and then give everyone an equal number of pieces.

Remember, $rac{a}{m}$ is made of $a$ copies of pieces of size $rac{1}{m}$; so what we do is cut all of the $rac{1}{m}$-chunks individually into $n$ pieces, and then give everyone $a$ of the little pieces we've made.
But "cut a $rac{1}{m}$-chunk into $n$ pieces" is just "cut an apple into $n$ pieces, but instead of doing it to one apple, do it to a $rac{1}{m}$-chunk": that is, it is $rac{1}{m} 	imes rac{1}{n}$, or $rac{1}{m 	imes n}$.

So the answer is just $$rac{a}{m} / n = rac{a}{m 	imes n}$$

## Example

[todo: pictorial example]

# Division by a negative integer

What would it even mean to divide an apple between four anti-people?
How about a simpler question: dividing an apple between one anti-person%%note:Remembering that dividing $x$ apples between one person just gives $x$, since there's not even any cutting of the apples necessary.%%? (The answer to this would be $rac{1}{-1}$.) It's not obvious!

Well, the thing to think about here is that if I take an apple, and share it among one person %%note:Myself, probably. I'm very selfish.%%, then I've got just the same apple as before (cut into no chunks): that is, $rac{1}{1} = 1$.
Also, if I take an apple and share it among one person who is *not* myself (and I don't give any apple to myself), then we've also just got the same unsliced apple as before: $rac{1}{1} = 1$ again.

But if I take an apple, and give it to an *anti*-person%%note:Being very careful not to touch them, because I would annihilate an anti-person!%%, then from their perspective *I*'m the anti-person, and I've just given them an anti-apple.
There's a law of symmetry built into reality: the laws of physics are invariant if we reflect "thing" and "anti-thing" throughout the universe.%%note:Technically this is not *quite* true: the actual symmetry is on reflecting charge, parity and time all together, rather than just parity alone. But for the purposes of this discussion, let's pretend that the universe is parity-symmetric.%%
The anti-person sees the universe in a way that's the same as my way, but where the "anti" status of everything (and everyantithing) is flipped.

[todo: write "the universe is unchanged on swapping anti-status" in the Negative Integers chunk too, around where we work out what -5+3 is, and say "remember this!"]

Put another way, "anti-ness" is not an absolute notion but a relative one.
I can only determine whether something is the same anti-ness or the opposite anti-ness to myself.

Sear this into your mind: the laws of rational-number "physics" are the same no matter who is observing.
If I observe a transaction, like "I, a person, give someone an apple", then an external person will observe "The author, a person, gave someone an apple", while an external anti-person will observe "The author, an anti-person, gave an anti-person an anti-apple".

From the external person's perspective, they saw "someone (of the same anti-ness as me) gave someone else (of the same anti-ness as me) an apple (of the same anti-ness as me)".
From the anti-person's perspective, everything is relatively the same: "someone (of the opposite anti-ness to me) gave someone else (of the opposite anti-ness to me) an apple (of the opposite anti-ness to me)".

So $rac{-1}{-1}$, being "one anti-apple shared among one anti-person", can be viewed instead from the perspective of an anti-person; they see one *apple* being given to one *person*: that is, $rac{-1}{-1}$ is equal to $1$.

Armed with the fact that $rac{-1}{-1} = 1$, we can just apply our usual multiplication rule that $rac{a}{m} 	imes rac{b}{n} = rac{a 	imes b}{m 	imes n}$, to deduce that $$rac{1}{-m} = rac{1}{-m} 	imes 1 = rac{1}{-m} 	imes rac{-1}{-1} = rac{-1 	imes 1}{-m 	imes -1} = rac{-1}{m}$$

The law of symmetry-of-the-universe basically says that $rac{a}{-b} = rac{-a}{b}$.

[todo: division by rational number]
[todo: division as "inverse of multiplication]

[todo: division by zero]

[todo: exercises]


Monotone function

Let $\langle P, \leq_P
angle$ and $\langle Q, \leq_Q
angle$ be [3rb posets]. Then a function $\phi : P
ightarrow Q$ is said to be **monotone** (alternatively, **order-preserving**) if for all $s, t \in P$, $s \le_P t$ implies $\phi(s) \le_Q \phi(t)$.

Positive example
------

![A simple monotone map phi](http://i.imgur.com/6w11VT2.png)

%%comment:
dot source:

digraph G {
  node [width = 0.1, height = 0.1]
  rankdir = BT;
  rank = same;
  compound = true;
  fontname="MathJax_Main";

  subgraph cluster_P {
    node [style=filled,color=white];
    edge [arrowhead = "none"];
    style = filled;
    color = lightgrey;
    fontcolor = black;
    label = "P";
    labelloc = b;
    b -> a;
    c -> a;

  }
  subgraph cluster_Q {
    node [style=filled];
    edge [arrowhead = "none"];
    color = black;
    fontcolor = black;
    label= "Q";
    labelloc = b;
    u -> t;
  }
  edge [color = blue, style = dashed]
  fontcolor = blue;
  label = "φ";
  labelloc = t;
  b -> t [constraint = false];
  a -> t [constraint = false];
  c -> u [constraint = false];
}

%%

Here is an example of a monotone map $\phi$ from a poset $P$ to another poset $Q$. Since $\le_P$ has two comparable pairs of elements, $(c,a)$ and $(b,a)$, there are two constraints that $\phi$ must satisfy to be considered monotone. Since $c \leq_P a$, we need $\phi(c) = u \leq_Q t = \phi(a)$. This is, in fact, the case. Also, since $b \leq_P a$, we need $\phi(b) = t \leq_Q t = \phi(a)$. This is also true.

Negative example
---------------

![A simple, non-monotone map](http://i.imgur.com/Zp0wSnP.png)

%%comment:
dot source:

digraph G {
  node [width = 0.1, height = 0.1]
  rankdir = BT;
  rank = same;
  compound = true;
  fontname="MathJax_Main";

  subgraph cluster_P {
    node [style=filled,color=white];
    edge [arrowhead = "none"];
    style = filled;
    color = lightgrey;
    fontcolor = black;
    label = "P";
    labelloc = b;
    a -> b;
  }

  subgraph cluster_Q {
    node [style=filled];
    edge [arrowhead = "none"];
    color = black;
    fontcolor = black;
    label= "Q";
    labelloc = b;
    w -> u;
    w -> v;
    u -> t;
    v -> t;
  }
  edge [color = blue, style = dashed]
  fontcolor = blue;
  label = "φ";
  labelloc = t;
  b -> u [constraint = false];
  a -> v [constraint = false];
}
%%

Here is an example of another map $\phi$ between two other posets $P$ and $Q$. This map is not monotone, because $a \leq_P b$ while $\phi(a) = v \parallel_Q u = \phi(b)$.

Additional material
----------------------------------

For some examples of montone functions and their applications, see [5lf]. To test your knowledge of monotone functions, head on over to [6pv].


Exponential notation for function spaces

If $X$ and $Y$ are sets, the set of functions from $X$ to $Y$ (often written $X 	o Y$) is sometimes also written $Y^X$. This latter notation, which we'll call *exponential notation*, is related to the notation for finite powers of sets (e.g., $Y^3$ for the set of triples of elements of $Y$) as well as the notation of exponentiation for numbers.

Without further ado, here are some reasons this is good notation.

- A function $f : X 	o Y$ can be thought of as an "$X$ wide" tuple of elements of $Y$. That is, a tuple of elements of $Y$ where the positions in the tuple are given by elements of $X$, generalizing the notation $Y^n$ which denotes the set of $n$ wide tuples of elements of $Y$. Note that if $|X| = n$, then $Y^X \cong Y^n$.

- This notion of exponentiation together with cartesian product as multiplication and disjoint union as addition satisfy the same relations as exponentiation, multiplication, and addition of natural numbers. Namely,

  - $Z^{X 	imes Y} \cong (Z^X)^Y$ (this isomorphism is called currying)
  - $Z^{X + Y} \cong Z^X 	imes Z^Y$
  - $Z^1 \cong Z$ (where $1$ is a one element set, since there is one function into $Z$ for every element of $Z$)
  - $Z^0 \cong 1$ (where $0$ is the empty set, since there is one function from the empty set to any set)

More generally, $Y^X$ is good notation for the exponential object representing $	ext{Hom}_{\mathcal{C}}(X, Y)$ in an arbitrary cartesian closed category $\mathcal{C}$ for the first set of reasons listed above.


Free group

[summary: The free [-3gd] $F(X)$ on the [3jz set] $X$ is the group whose elements are the [5jc freely reduced words] over $X$, and whose group operation is "[-concatenation] followed by free reduction".]

Intuitively, the free [-3gd] $F(X)$ on the [3jz set] $X$ is the group whose elements are the [5jc freely reduced words] over $X$, and whose group operation is "[-concatenation] followed by free reduction".

The free group can be constructed rigorously in several equivalent ways, some of which are easy to construct but hard to understand, and some of which are intuitive but rather hard to define properly.
Our formal construction (detailed on the [5s1 Formal Definition lens]) will be one of the more opaque definitions; there, we eventually show that the formal construction yields a group which is [49x isomorphic] to the intuitive version, and this will prove that the intuitive version does in fact define a group with the right properties for the free group.

# Intuitive definition

Given a set $X$, the free group $F(X)$ (or $FX$) on $X$ has:

- as its elements, the [5jc freely reduced words] over $X$;
- as its group [3h7 operation], "concatenation followed by free reduction".

## Example

The free group on the set $X = \{ a, b \}$ contains the following elements (among others):

- The word $(a,b,a,a,a,b^{-1})$, which is written in shorthand as $abaaab^{-1}$ or (most commonly) as $aba^3b^{-1}$
- The empty word $()$, which is written as $arepsilon$
- The word $(b,b,b)$, which is written as $b^3$
- The word $(a^{-1}, b^{-1}, b^{-1})$, or $a^{-1} b^{-2}$

(From now on, we will only use the common shorthand to denote words, except in cases where this interferes with something else we're doing.)

Some things which the same free group does *not* contain are:

- $aa^{-1}$, since this is not freely reduced
- $c$, for the fatuous reason that $c$ is not a word over the alphabet $\{a,b\}$
- $abb^{-1}a$, since this is not freely reduced.

Some examples of this group's group operation (which we will write as $\cdot$) in action are:

- $aba \cdot bab = ababab$
- $aba^2 \cdot a^3b = aba^5b$
- $aba^{-1} \cdot a = ab$, obtained as the free reduction of $aba^{-1}a$
- $ab \cdot b^{-1} a^{-1} = arepsilon$, obtained as $abb^{-1}a^{-1} = aa^{-1}$ (reduction of $b$) and then $a a^{-1} = arepsilon$.

# Examples

- The free group on the empty set is just the trivial group, the group with just one element. Indeed, we must have an identity (the empty word), but there are no extra generators to throw in, so there are no longer words.
- The free group on a set with one element is isomorphic to the group of integers under addition. Indeed, say our set is $\{ a \}$; then every member of the free group is a word of the form $a^n$ or $a^{-n}$ or $a^0$. Then the isomorphism is that $a^i$ is sent to $i \in \mathbb{Z}$.
- The free group on two elements is [2w0 countable]. Indeed, its elements are all of the form $a^{i_1} b^{j_1} a^{i_2} b^{j_2} \dots a^{i_n} b^{j_n}$, and so the free group [4b7 injects] into the [45h set of natural numbers] by the (rather convoluted) $$a^{i_1} b^{j_1} a^{i_2} b^{j_2} \dots a^{i_n} b^{j_n} \mapsto 2^{\mathrm{sgn}(i_1)+2} 3^{|i_1|} 5^{\mathrm{sgn}(j_1)+2} 7^{|j_1|} \dots$$
where we produce the natural number %%note:Uniquely, by the [-5rh].%% whose prime factors tell us exactly how to construct the original word. %%note:This trick is extremely useful in determining whether a set is countable, and you should go over it until you are sure you understand it.%% (The $\mathrm{sgn}$ function outputs $-1$ if its input is negative; $1$ if the input is positive; and $0$ if its input is $0$.)
As a related exercise, you should prove that the free group on a countable set is countable.

# Why are the free groups important?

It is a fact that [-5jb].
Therefore the free groups can be considered as a kind of collection of "base groups" from which all other groups can be made as quotients.
This idea is made more concrete by the idea of the [-5j9], which is a notation that specifies a group as a quotient of a free group. %%note:Although it's not usually presented in this way at first, because the notation has a fairly intuitive meaning on its own.%%

## Free groups "have no more relations than they are forced to have"

The crux of the idea of the group presentation is that the free group is the group we get when we take all the elements of the set $X$ as elements which "generate" our putative group, and then throw in every possible combination of those "generators" so as to complete it into a bona fide group.
We explain why the free group is (informally) a "pure" way of doing this, by walking through an example.

%%%hidden(Example):
If we want a group which contains the elements of $X = \{ a, b \}$, then what we *could* do is make it into the [-47y] on the two elements, $C_2$, by insisting that $a$ be the [54p identity] of the group and that $b \cdot b = a$.
However, this is a very ad-hoc, "non-pure" way of making a group out of $X$. %%note:For those who are looking out for that sort of thing, to do this in generality will require heavy use of the [69b axiom of choice].%%
It adds the "relation" $b^2 = a$ which wasn't there before.

Instead, we might make the free group $FX$ by taking the two elements $a, b$, and throwing in everything we are forced to make if no non-trivial combination is the identity.
For example:

- we have no reason to suspect that either $a$ or $b$ is already the identity, so we must throw in an identity which we will label $arepsilon$;
- we have no reason to suspect that $a \cdot b$ should be equal to $a$ or to $b$ or to $arepsilon$, so we must throw in an element equal to $a \cdot b$ which we will label $ab$;
- we *do* have a reason to suspect that $a^{-1} \cdot a$ is already in the group (because it "ought to be" the identity $arepsilon$), so we don't throw in the element $a^{-1} a$;
- and so on through all the words, such as $a^{-1}ba^2b^{-2}$ and so forth.

This way adds an awfully large number of elements, but it doesn't require us to impose any arbitrary relations.
%%%

# Universal property of the free group

The free group [free_group_universal_property has a universal property], letting us view groups from the viewpoint of [-4c7].
Together with the idea of the [4tq quotient] (which can be formulated in category theory as the [-coequaliser]) and the subsequent idea of the [-5j9], this lets us construct any group in a category-theoretic way.

Indeed, every group $G$ has a presentation $\langle X \mid R
angle$ say, which expresses $G$ as a quotient (i.e. a certain coequaliser) of the free group $F(X)$.
We can construct $F(X)$ through the universal property, so we no longer need to say anything at all about the elements or group operation of $G$ to define it.

# Properties

- It is not obvious, but $FX$ is isomorphic to $FY$ if and only if $X$ and $Y$ have the same [-4w5] as sets. ([free_group_isomorphic_iff_sets_biject Proof.]) This completely classifies the free groups and tells us just when two free groups are "the same", which is nice to have.
- The only two [3h2 abelian groups] which are free are the trivial group (of one element; i.e. the free group on no generators), and $\mathbb{Z}$ the free group on one generator. No others are abelian because if there are two or more generators, pick $a, b$ to be two of them; then $ab
ot = ba$ by free-ness. %%note: To be completely precise about this, using the [5s1 formal definition], $
ho_a
ho_b
ot =
ho_b
ho_a$ because they have different effects when applied to the empty word $arepsilon$. One produces $ab$; the other produces $ba$. %%
- The free groups are all [torsion_group_theory torsion]-free %%note:"Torsion-free" means "free of torsion", where the word "free" is nothing to do with "free group".%%: that is, no element has finite [4cq order] unless it is the identity $arepsilon$. ([5kz Proof.]) This property helps us to recognise when a group is *not* free: it is enough to identify an element of finite order. However, the test doesn't go the other way, because there are torsion-free groups which are not free.

%%hidden(Proof that "the rationals under addition" is torsion-free but not free):
Suppose the order of an element $x \in \mathbb{Q}$ were finite and equal to $n
ot = 0$, say.
Then $x+x+\dots+x$, $n$ times, would yield $0$ (the [54p identity] of $(\mathbb{Q}, +)$).
But that would mean $n 	imes x = 0$, and so $n=0$ or $x = 0$; since $n
ot = 0$ already, we must have $x = 0$, so $x$ is the identity after all.

The group is not free: suppose it were free. It is abelian, so it must be isomorphic to either the trivial group (clearly not: $\mathbb{Q}$ is infinite but the trivial group isn't) or $\mathbb{Z}$.
It's not isomorphic to $\mathbb{Z}$, though, because $\mathbb{Z}$ is cyclic: there is a "generating" element $1$ such that every element of $\mathbb{Z}$ can be made by adding together (possibly negatively-many) copies of $1$.
$\mathbb{Q}$ doesn't have this property, because if $x$ were our attempt at such a generating element, then $rac{x}{2}$ could not be made, so $x$ couldn't actually be generating after all.
%%


Consistency

A consistent [-theory] is one in which there are well-formed statements that you cannot prove from its axioms; or equivalently, that there is no $X$ such that $T\vdash X$ and $T\vdash \neg X$.

From the point of view of [-model_theory], a consistent theory is one whose axioms are [-satisfiable]. Thus, to prove that a set of axioms is consistent you can resort to constructing a model using a formal system whose consistency you trust (normally using [set_theory]) in which all the axioms come true.

Arithmetic is [ expressive enough] to talk about consistency within itself. If $\square_{PA}$ represents the [-5gt] in [3ft] then a sentence of the form $\neg\square_{PA}(\ulcorner 0=1\urcorner)$ represents the consistency of $PA$, since it comes to say that there exists a disprovable sentence for which there is no proof. [ Gödel's second incompleteness theorem] comes to say that such a sentence is not provable from the axioms of $PA$.


Free groups are torsion-free

Given the [-5kg] $FX$ on a set $X$, it is the case that $FX$ has no [torsion_group_theory torsion] elements.
That is, every element has infinite order except for the [-54p].

# Proof

Recall that we can view every element of the free group as being a [-5jc] whose letters are elements of $X$.
Also the group operation is "concatenation of words, followed by free reduction".
It is certainly intuitively plausible that if we repeatedly concatenate a word with more copies of itself, and then perform free reduction, we will never reach the empty word; this is what we shall prove.
The cancellations in the process of free reduction are everything here, because the only way the powers of a word can get shorter (and hence the only way the powers of a word can ever come to the empty word) is by those cancellations.
So we are going to have to analyse the behaviour of words at their start and ends, because when we take powers of a word, the start and end are the places where cancellation may happen.

We will say a word is *cyclically reduced* if it is not only freely reduced, but also it is "freely reduced if we rotate the word round one place".
Formally, a freely reduced word $a_1 a_2 \dots a_n$ is cyclically reduced if and only if $a_1
ot = a_n^{-1}$.
This captures the idea that "the word doesn't admit any cancellation when we take powers of it".

%%hidden(Examples):
[todo: some examples of words which are cyclically reduced and some which are not]
%%

Now, every freely reduced word may $w$ be written as $r w^\prime r^{-1}$ where $r$ is a freely reduced word and $w^\prime$ is a cyclically reduced word, and there is no cancellation between $r$, $r^{-1}$ and $w^\prime$.
This is easily proved by [-5fz] on the length of $w$: it is immediate if $w$ is already cyclically reduced (letting $r = arepsilon$ the empty word, and $w^\prime = w$), while if $w$ is not cyclically reduced then it is $a v a^{-1}$ for some letter $a \in X$ and some freely reduced word $v$.
But then by the inductive hypothesis (since $v$ is shorter than $w$), $v$ may be written as $r v^\prime r^{-1}$ where $v^\prime$ is cyclically reduced; so $w = a r v^\prime r^{-1} a^{-1} = (ar) v^\prime (ar)^{-1}$ as required.

Moreover, this decomposition is *unique*, since if $r w^\prime r^{-1} = s v^\prime s^{-1}$ then $s^{-1} r w^\prime r^{-1} s = v^\prime$; but $v^\prime$ is cyclically reduced so there are only two ways to prevent cancellation:

- $s$ is the identity, whereupon $v^\prime = r w^\prime r^{-1}$ is cyclically reduced, so (by freely-reducedness of $w = r w^\prime r^{-1}$) we have $r = e$ as well, and $v^\prime = w^\prime = w$.
- $s$ is not the identity but it entirely cancels with something in $r^{-1}$; hence $s$ is a sub-word of $r$. But by symmetry, $r$ is a sub-word of $s$, so they are the same (because without loss of generality $r$ is also not the identity); and therefore $v^\prime = w^\prime$.

Finally, to complete the proof that the free group is torsion-free, simply take a putative word $w$ whose order $n$ is finite.
Express it uniquely as $r w^\prime r^{-1}$ as above; then $(rw^\prime r^{-1})^n = r (w^\prime)^n r^{-1}$ which is expected to become the empty word after free reduction.
But we already know there is no cancellation between $r$ and $w^\prime$ and $r^{-1}$, so there cannot be any cancellation between $r, (w^\prime)^n, r^{-1}$ either, and by the cyclically-reduced nature of $w^\prime$, our power $r (w^\prime)^n r^{-1}$ is actually freely reduced already.
Hence our power of the word is emphatically not the empty word.


Provability logic

The Gödel -Löb system of provability logic, or $GL$ for short, is a [-5j8] which captures important notions about [5j7 provability predicates]. It can be regarded as a formalism which allows to decide whether certain sentences in which a provability predicate appears are in fact theorems of [3ft].

$GL$ has two rules of inference:

* **Modus ponens** allows to infer $B$ from $A	o B$ and $A$.
* **Necessitation** says that if $GLdash A$ then $GLdash \square A$.

The axioms of $GL$ are as follows:

* $GLdash \square (A	o B)	o(\square A 	o \square B)$ (**Distibutive axioms**)
* $GLdash \square (\square A 	o A)	o \square A$ (**Gödel-Löb axioms**)
* Propositional tautologies are axioms of $GL$.

**Exercise**: Show using the rules of $GL$ that $\square ot \leftrightarrow \square \diamond p$. %%note:$\diamond p$ is short for $
eg \square
eg p$.%%

%%hidden(Show solution):
Those problems are best solved by working backwards.

We want to show that $GLdash \square ot \leftrightarrow \square \diamond p$.

What can lead us to that? Well, we know that because of [ normality], this can be deduced from $GLdash \square (ot \leftrightarrow \diamond p)$.

Similarly, that can be derived from necessitation of $GLdash ot \leftrightarrow \diamond p$.

The propositional calculus shows that $GLdash ot 	o \diamond p$ is a tautology, so we can prove by following the steps backward that $GLdash \square ot 	o \square \diamond p$.

Now we have to prove that $GLdash \square \diamond p	o \square ot$ and we are done.

For that we are going to go forward from the tautology $GLdash ot 	o
eg p$.

By normality, $GLdash \square ot 	o \square
eg p$.

Contraposing, $Gldash
eg \square
eg p	o
eg\squareot$. By necessitation and normality, $Gldash \square
eg \square
eg p	o\square
eg\squareot$.

But $\square
eg\squareot$ is equivalent to $\square[\square ot 	o ot]$, and it is an axiom that $GLdash \square[\square ot 	o ot] 	o\square ot$, so by modus ponens, $Gldash \square
eg \square
eg p	o\square ot$, and since $\diamond p =
eg \square
eg p$ we are done.
%%

It is fairly easy to see that GL is consistent. If we interpret $\square$ as the verum operator which is always true, we realize that every theorem of $GL$ is assigned a value of true according to this interpretation and the usual rules of propositional calculus %%note:[ proof] %%. However, there are well formed modal sentences such as $
eg \square ot$ such that the assigned value is false, and thus they cannot be theorems of $GL$.

##Semantics
However simple the deduction procedures of $GL$ are, they are bothersome to use in order to find proofs. Thankfully, an alternative interpretation in terms of [5ll Kripke models] has been developed that allows to decide far more conveniently whether a modal sentence is a theorem of $GL$.

$GL$ is adequate for finite, transitive and irreflexive Kripke models. That is, a sentence $A$ is a theorem of $GL$ if and only if $A$ is valid in every finite, transitive and irreflexive model%%note: [ proof]%%. Check out the page on Kripke models if you do not know how to construct Kripke models or decide if a sentence is valid in it.

An important notion in this kind of models is that of *rank*. The rank $
ho$ of a world $w$ from which no world is visible is $
ho(w)=0$. The rank of any other world is defined as the maximum among the ranks of its successors, plus one. In other words, the rank of a world is the length of the greatest "chain of worlds" in the model such that $w$ can view the first slate of the chain.

Since models are irreflexive and finite, the rank is a well-defined notion: no infinite chain of worlds is ever possible.

**Exercise**: Show that the Gödel-Löb axioms are valid in every finite, transitive and irreflexive Kripke model.

%%hidden(Show solution):
Suppose there is a finite, transitive and irreflexive Kripke model in which an sentence of the form $\square[\square A	o A]	o \square A$ is not valid.

Let $w$ be the lowest rank world in the model such that $w
ot\models \square[\square A	o A]	o \square A$. Then we have that $w\models \square[\square A	o A]$ but $w
ot \models \square A$.

Therefore, there exists $x$ such that $w R x$, also $x\models
eg A$ and $x\models \square A	o A$. But then $x\models
eg\square A$.

Since $x$ has lower rank than $w$, we also have that $x\models \square[\square A	o A]	o \square A$. Combining those two last facts we get that $x
ot\models \square[\square A	o A]$, so there is $y$ such that $xRy$ and $y
ot\models \square A	o A$.

But by transitivity $wRy$, contradicting that $w\models \square[\square A	o A]$. So the supposition was false, and the proof is done.
%%

The Kripke model formulation specially simplifies reasoning in cases in which [constant_sentences no sentence letters appear]. A polynomial time algorithm can be written for deciding theoremhood this case.

Furthermore, $GL$ is [-decidable]. However, it is [ $PSPACE$-complete] %%note:[ proof]%%.

##Arithmetical adequacy
You can translate sentences of modal logic to sentences of arithmetic using *realizations*.

A realization $*$ is a function such that
$A	o B*=A*	o B*$,
$(\square A)* =\square_{PA}(A*)$,
and $p* = S_p$ for every sentence letter $p$, where each $S_p$ is an arbitrary well formed closed sentence of arithmetic.

[ Solovay's adequacy theorem for GL] states that a modal sentence $A$ is a theorem of $GL$ iff $PA$ proves $A*$ for every realization $*$.

Thus we can use $GL$ to reason about arithmetic and viceversa.

Notice that $GL$ is decidable while [ arithmetic is not]. This is explained by the fact that $GL$ only deals with a specific subset of logical sentences, in which quantification plays a restricted role. In fact, quantified provability logic is undecidable.

Another remark is that while knowing that $GL
otdash A$ implies that there is a realization such that $PA
otdash A*$, we do not know whether a specific realization of A is a theorem or not. A related result, the [ uniform completeness theorem for $GL$], proves that there exists a specific realization $\#$ such that $PA
ot dash A^{\#}$ if $GL
otdash A$, which works for every $A$.

##Fixed points
One of the most important results in $GL$ is the existence of fixed points of sentences of the form $p\leftrightarrow \phi(p)$. Concretely, the [ fixed point theorem] says that for every sentence $\phi(p)$ modalized in $p$ %%note:that is, every $p$ occurs within the scope of a $\square$%% there exists $H$ in which $p$ does not appear such that $GLdash \square [p\leftrightarrow \phi(p)] \leftrightarrow \square (p\leftrightarrow h)$. Furthermore, there are constructive proofs which allow to build such an $H$.

In arithmetic, there are plenty of interesting [59c self referential sentences] such as the [godel_first_incompleteness_theorem Gödel sentence] for which the fixed point theorem is applicable and gives us insights about their meaning.

For example, the modalization of the Gödel sentence is something of the form $p\leftrightarrow
eg\square p$. The procedure for finding fixed points tells us that $GLdash \square (p\leftrightarrow
eg\square p)	o \square(p\leftrightarrow
eg\squareot$. Thus by arithmetical adequacy, and since [ everything $PA$ proves is true]  we can conclude that the Gödel sentence is equivalent to the [5km consistency of arithmetic].


Monotone function: examples

Here are some examples of monotone functions.

A cunning plan
--------

There's a two-player game called 10 questions, in which player A begins the game by stating "I'm thinking of an X", where X can be replaced with any noun of player A's choosing.

Then player B asks player A a series of questions, which player A must answer with either truthfully with "yes" or "no". After asking 10 questions, player B is forced to guess what the object player A was thinking of. Player B wins if the guess is correct, and loses otherwise. Player B may guess before 10 turns have expired, in which case the guess counts as one of
their questions.

Here is an example of a game of 10 questions:

A: I'm thinking of a food.

Question 1.
B: Is it healthy?
A: Yes.

Question 2.
B: Is it crunchy?
A: No.

Question 3.
B: Must it be prepared before it is eaten?
A: No.

Question 4.
B: Is yellow?
A: Yes.

Question 5.
B: Is it a banana?
A: Yes.

**Player B wins**

Now suppose that you are playing 10 questions as player B. Player A begins by stating
"I'm thinking of a letter of the alphabet." You immediately think of a strategy
that requires no more than 5 guesses: repeatedly ask "does it come after $\star$?"
where $\star$ is near the middle of the contiguous sequence of letters that you have
not yet eliminated. Initially the contiguous sequence of letters between A and Z
have not been eliminated.

Question 1.
*You:* Does it come after M?
*Player A:* Yes.

At this point, the contiguous sequence of 13 letters that have not been eliminated is N-Z,
inclusive.

Question 2.
*You:* Does it come after S? *Player A:* No.

At this point, the contiguous sequence of 6 letters that have not been eliminated is N-S,
inclusive.

Question 3. *You:* Does it come after P?  *Player A:* Yes.

We've now narrowed it down to Q,R,and S.

Question 4. *You:* Does it come after R? *Player A:* No.

Question 5. *You:* Does it come after Q? *Player A:* No.

*You:* Is it Q? *Player A:* Yes.

**You win**

But what does this have to do with monotone functions? The letters of the alphabet form a poset $Alph = \langle \{A,...,Z\}, \leq_{Alph}
angle$ (in fact, a [540 totally ordered set]) under the standard alphabetic order. Your strategy for playing 10 questions can be viewed as probing a monotone function from $Alph$ to the 2-element poset **2** of a [57f boolean values], where $false <_{	extbf{2}} true$. Specifically, the probed function $f : Alph 	o 	extbf{2}$ is defined such that $f(\star) \doteq Q >_{Alph} \star$

The monotonicity of $f$ is crucial to being able to eliminate possibilities at each step. If we probe $f$ at a letter $\star_1$ and observe a false result, then any letter $\star_2$ less than $\star_1$ must map to false as well: $\star_2 \leq_{Alph} \star_1$ implies $f(\star_2) \leq_{	extbf{2}} f(\star_1)$. Yes, we can demonstrate the aformentioned monotone function with a diagram, but since its size is unwieldy, it has been placed in the following hidden text block.

%%hidden(Show solution):
![Diagram of f](http://i.imgur.com/ILepmis.png)
%%

Deduction systems
---------------

[deduction_systems] allow one to infer new judgments from a set of known judgments. They are often specified as a set of rules, in which each rule is represented as a horizontal bar with one or more premises appearing above the bar and a conclusion that can be deduced from those premises appearing below the bar.

![A deduction system](http://i.imgur.com/OFx6REF.png)

The above rules form a fragment of [57f propositional logic]. $\phi$ and $\psi$ are used to denote logical statements, called *propositions*. $\wedge$ and $	o$ are binary logical operators, each of which maps a pair of propositions to a single proposition. $\wedge$ is the *and* operator: if $\phi$ and $\psi$ are logical statements, then $\phi \wedge \psi$ is the simultaneous assertion of both $\phi$ and $\psi$. $	o$ is the *implication* operator: $\phi 	o \psi$ asserts that if we know $\phi$ to be true, then we can conclude $\psi$ is true as well.

The leftmost rule has two premises $\phi$ and $\psi$, and concludes from these premises the proposition $\phi \wedge \psi$. Invoking a rule to deduce its conclusion from its premises is called *applying* the rule. A tree of rule applications is called a [proof proof].

Deduction systems are often viewed as proof languages. However, it can also be fruitful to view a deduction system as a function which, given a set of input propositions, produces the set of all propositions that can be concluded from exactly one rule application, using the input propositions as premises. More concretely, letting $X$ be the set of propositions, the above set of deduction rules corresponds to the following function $F : \mathcal P(X) 	o \mathcal P(X)$.

$F(A) = \ ~~ \{ \phi \wedge \psi\mid\phi \in A, \psi \in A \} \cup \ ~~ \{ \phi \mid \phi \wedge \psi \in A \} \cup \ ~~ \{ \psi \mid \phi \wedge \psi \in A \} \cup \ ~~ \{ \phi \mid \psi \in A, \psi 	o \phi \in A \}$

$F$ is a montone function from the poset $\langle \mathcal P(X), \subseteq
angle$ to itself. The reason that $F$ is monotone is that larger input sets give us more ways to apply the rules of our system, yielding larger outputs.

In addition to standard logical notions, deduction systems can be used to describe [type_system type systems], [program_logic program logics], and [operational_semantics operational semantics].

Additional material
-------------

If you still haven't had enough monotonicity, might I recommend trying some of the [6pv exercises]?

%comment:
Increasing functions
----------------

A monotone function between two [540 totally ordered sets] is called increasing. For example, the graph of a monotone function from the poset $\langle \mathbb R, \le
angle$ to itself has an upward slope. Such functions can be searched efficiently using the [binary_search binary search algorithm].
%


Kripke model

**Kripke models** are [ interpretations] of [-534] which turn out to be adequate under some basic constraints for a wide array of systems of modal logic.

#Definition
A Kripke model $M$ is formed by three elements:

* A set of **worlds** $W$
* A **visibility relationship** between worlds $R$. If $wRx$, we will say that $w$ sees $x$ or that $x$ is a successor of $w$.
* A **valuation function** $V$ that associates pairs of worlds and sentence letters to truth values.

You can visualize Kripke worlds as a [-digraph] in which each node is a world, and the edges represent visibility.

[todo: images of Kripke worlds]

The valuation function can be extended to assign truth values to whole modal sentences. We will say that a world $w\in W$ makes a modal sentence $A$ true (*notation*: $M,w\models A$) if it is assigned a truth value of true according to the following rules:

* If $A$ is a sentence letter $p$, then $M,w\models p$ if $V(w,p)=	op$.
* If $A$ is a truth functional compound of sentences, then its value comes from the propositional calculus and the values of its components. For example, if $A=B	o C$, then $M,w\models A$ [-46m] $M,w
ot\models B$ or $M,w\models C$.
* If $A$ is of the form $\square B$, then $M,w\models \square B$ if $M,x\models B$ for every successor $x$ of $w$.

Given this way of assigning truth values to sentences, we will say the following:

* $A$ is valid in a model $M$ (*notation*: $M\models A$) if $M,w\models A$ for every $w$ in $W$.
* $A$ is valid in a class of models if it is valid in every model of the class.
* $A$ is satisfiable in a model $M$ if there exists $w\in W$ such that $M,w\models A$.
* $A$ is satisfiable in a class of models if it is satisfiable in some model of the class.

Notice that a sentence $A$ is valid in a class of models iff its negation is not satisfiable.

#Kripke models as semantics of modal logic
Kripke models are tightly connected to the interpretations of certain modal logics.

For example, they model well the rules of [5j8 normal provability systems].

**Exercise**: show that Kripke models satisfy the necessitation rule of modal logic. That is, if $A$ is valid in $M$, then $\square A$ is valid in $M$.

%%hidden(Show solution):
Let $w\inW$ be a world of $M$. Let $x$ be an arbitrary successor of $w$. Then, as $M\models A$, then $M,x\models A$. Since $x$ was arbitrary, every successor of $w$ models $A$, so $w\models \square A$. As $w$ was arbitrary, then every world in $M$ models $\square A$, and thus $M\models \square A$.
%%

**Exercise**: Show that the distributive axioms are always valid in Kripke models. Distributive axioms are modal sentences of the form $\square[A	o B]	o(\square A 	o \square B)$.

%%hidden(Show solution):
Suppose that $w\in W$ is such that $w\models \square[A	o B]$ and $w\models \square A$.

Let $x$ be a successor of $w$. Then $x\models A	o B$ and $x\models A$. We conclude by the propositional calculus that $x\models B$, so as $x$ was an arbitrary successor we have that $w\models \square B$, and thus $w\models\square[A	o B]	o(\square A 	o \square B)$.

We conclude that $M\models\square[A	o B]	o(\square A 	o \square B)$, no matter what $M$ is.
%%

Those two last exercises prove that the [ K system] of modal logic is [soundness sound] for the class of all Kripke models. This is because we have proved that its axioms and rules of inference hold in all Kripke models (propositional tautologies and modus ponens trivially hold).

##Some adequacy theorems
Now we present a relation of modal logics and the class of Kripke models in which they are [adequacy adequate]. You can check the proofs of adequacy in their respective pages.

* The class of *all* Kripke models is adequate to the [ K system]
* The class of [573 transitive] Kripke models is adequate to [ K4]
* The class of [ reflexive] Kripke models is adequate to [ T]
* The class of [ reflexive] and [573 transitive] Kripke models is adequate to [ S4]
* The class of [ reflexive] and [ symmetric] Kripke models is adequate to [ B]
* The class of [ reflexive] and [ euclidean] Kripke models is adequate to [ S5]
* The class of [ finite], [ irreflexive] and [573 transitive] Kripke models is adequate to [5l3 GL]

Notice that as the constraint on the models becomes stronger, the set of valid sentences increases, and thus the correspondent adequate system is stronger.

A note about notation may be in order. We say that a Kripke model is, e.g, [573 transitive] if its visibility relation is transitive %%note:Same for reflexive, symmetric and euclidean %%. Similarly, a Kripke model is finite if its set of worlds is finite.


Antisymmetric relation

An antisymmetric relation is a relation where no two distinct elements are related in both directions. In other words. $R$ is antisymmetric iff

$(aRb ∧ bRa) → a = b$

or, equivalently, $a ≠ b → (¬aRb ∨ ¬bRa)$

Antisymmetry isn't quite the [set_theory_compliment compliment] of [symmetric_relation Symmetry]. Due to the fact that $aRa$ is allowed in an antisymmetric relation, the equivalence relation, $\{(0,0), (1,1), (2,2)...\}$ is both symmetric and antisymmetric.

Examples of antisymmetric relations also include the successor relation, $\{(0,1), (1,2), (2,3), (3,4)...\}$, or this relation linking numbers to their prime factors $\{...(9,3),(10,5),(10,2),(14,7),(14,2)...)\}$


Fixed point theorem of provability logic

[summary:
>Let $\phi(p, q_1,...,q_n)$ be a modal sentence [5m4 modalized] in $p$.
>Then there exists a sentence $H(q_1,..,q_n)$ such that $GL\vdash \boxdot[p\leftrightarrow \phi(p,q_1,...,q_n)] \leftrightarrow \boxdot[p\leftrightarrow H(q_1,..,q_n)]$.

This result can be used to give us insight about [59c self-referent] sentences of arithmetic.
]

The fixed point theorem of provability logic is a key result that gives a explicit procedure to find equivalences for sentences such as the ones produced by the [-59c].

In its most simple formulation, it states that:

>Let $\phi(p)$ be a modal sentence [5m4 modalized] in $p$. Then there exists a letterless $H$ such that $GL\vdash \boxdot[p\leftrightarrow \phi(p)] \leftrightarrow \boxdot[p\leftrightarrow H]$ %%note: Notation: $\boxdot A = A\wedge \square A$%%.

This result can be generalized for cases in which letter sentences other than $p$ appear in the original formula, and the case where multiple formulas are present.

#Fixed points
The $H$ that appears in the statement of the theorem is called a **fixed point** of $\phi(p)$ on $p$.

In general, a fixed point of a formula $\psi(p, q_1...,q_n)$ on $p$ will be a modal formula $H(q_1,...,q_n)$ in which $p$ does not appear such that $GL\vdash \boxdot[p\leftrightarrow\psi(p, q_1,...,q_n)] \leftrightarrow \boxdot[p_i\leftrightarrow H(q_1,...,q_n)]$.

The fixed point theorem gives a sufficient condition for the existence of fixed points, namely that $\psi$ is modalized in $\psi$. It is an open problem to determine a necessary condition for the existence of fixed points.

Fixed points satisfy some important properties:

If $H$ is a fixed point of $\phi$ on $p$, then $GL\vdash H(q_1,...,q_n)\leftrightarrow \phi(H(q_1,...,q_n),q_1,...,q_n)$. This coincides with our intuition of what a fixed point is, since this can be seen as an argument that when fed to $\phi$ it returns something equivalent to itself.

%%hidden(Proof):
Since $H$ is a fixed point, $GL\vdash \boxdot[p\leftrightarrow\psi(p, q_1,...,q_n)] \leftrightarrow \boxdot[p_i\leftrightarrow H(q_1,...,q_n)]$. Since $GL$ is [ normal], it is closed under substitution. By substituing $p$ for $H$, we find that $GL\vdash \boxdot[H(q_1,...,q_n)\leftrightarrow\psi(H(q_1,...,q_n), q_1,...,q_n)] \leftrightarrow \boxdot[H(q_1,...,q_n)\leftrightarrow H(q_1,...,q_n)]$.

But trivially $GL\vdash \boxdot[H(q_1,...,q_n)\leftrightarrow H(q_1,...,q_n)$, so $GL\vdash \boxdot[H(q_1,...,q_n)\leftrightarrow\psi(H(q_1,...,q_n), q_1,...,q_n)]$.
%%

$H$ and $I$ are fixed points of $\phi$ if and only if $GL\vdash H\leftrightarrow I$. This is knows as the
**uniqueness of fixed points**.

%%hidden(Proof):
Let $H$ be a fixed point on $p$ of $\phi(p)$; that is, $GL\vdash \boxdot(p\leftrightarrow \phi(p))\leftrightarrow (p\leftrightarrow H)$.

Suppose $I$ is such that $GL\vdash H\leftrightarrow I$. Then by the first substitution theorem,  $GL\vdash F(I)\leftrightarrow F(H)$ for every formula $F(q)$. If $F(q)=\boxdot(p\leftrightarrow q)$, then $GL\vdash \boxdot(p\leftrightarrow H)\leftrightarrow \boxdot(p\leftrightarrow I)$, from which it follows that $GL\vdash \boxdot(p\leftrightarrow \phi(p))\leftrightarrow (p\leftrightarrow I)$.

Conversely, if $H$ and $I$ are fixed points, then $GL\vdash \boxdot (p\leftrightarrow H)\leftrightarrow \boxdot (p\leftrightarrow I)$, so since $GL$ is closed under substitution, $GL\vdash\boxdot (H\leftrightarrow H)\leftrightarrow \boxdot (H\leftrightarrow I)$. Since $GL\vdash \boxdot (H\leftrightarrow H)$, it follows that $GL\vdash (H\leftrightarrow I)$.
%%

#Special case fixed point theorem

The special case of the fixed point theorem is what we stated at the beginning of the page. Namely:

>Let $\phi(p)$ be a modal sentence [5m4 modalized] in p.
>Then there exists a letterless $H$ such that $GL\vdash \boxdot[p\leftrightarrow \phi(p)] \leftrightarrow \boxdot[p\leftrightarrow H]$.

There is a nice semantical procedure based on [5ll Kripke models]  that allows to compute $H$ as a truth functional compound of sentences $\square^n \bot$ %%note:$\square^n A = \underbrace{\square,\square,\ldots,\square}_{n\text{-times}} A$ %%. (ie, $H$ is in [ normal form]).

##$A$-traces
Let $A$ be a modal sentence modalized in $p$ in which no other sentence letter appears (we call such a sentence a $p$-sentence). We want to calculate $A$'s fixed point on $p$. This procedure bears a resemblance to the [ trace] method for evaluating letterless modal sentences.

We are going to introduce the notion of the $A$-trace of a $p$-sentence $B$, notated by $[[B]]_A$. The $A$-trace maps modal sentences to sets of [45h natural numbers], and is defined recursively as follows:

* $[[\bot]]_A = \emptyset$
* $[[B\to C]]_A = (\mathbb{N} \setminus [[B]]_A)\cup [[C]]_A$
* $[[\square D]]_A=\{m:\forall i < m i\in [[D]]_A\}$
* $[[p]]_A=[[A]]_A$

*Lemma*: Let $M$ be a finite, transitive and irreflexive Kripke model in which $(p\leftrightarrow A) is valid, and $B$ a $p$-sentence. Then $M,w\models B$ iff $\rho(w)\in [[B]]_A$.

%%hidden(Proof):
Coming soon [todo: proof]
%%

*Lemma*: The $A$-trace of a $p$-sentence $B$ is either finite or cofinite, and furthermore either it has less than $n$ elements or lacks less than $n$ elements, where $n$ is the number of $\square$s in $A$.

%%hidden(Proof):
Coming soon [todo: proof]
%%

Those two lemmas allow us to express the truth value of $A$ in terms of world ranks for models in which $p\leftrightarrow A$ is valid. Then the fixed point $H$ will be either the union or the negation of the union of a finite number of sentences $\square^{n+1}\bot\wedge \square^n \bot$ %%note:Such a sentence is only true in worlds of rank $n$%%

In the following section we work through an example, and demonstrate how can we easily compute those fixed points using a [ Kripke chain].

##Applications

For an example, we will compute the fixed point for the modal [ Gödel sentence] $p\leftrightarrow \neg\square p$ and analyze its significance.

We start by examining the truth value of $\neg\square p$ in the $0$th rank worlds. Since the only letter is $p$ and it is modalized, this can be done without problem (remember that $\square B$ is always true in the rank $0$ worlds, no mater what $B$ is). Now we apply to $p$ the constraint of having the same truth value as $\neg\square p$.

We iterate the procedure for the next world ranks.

$$
\begin{array}{cccc}
 \text{world= } & p & \square (p) & \neg \square (p) \\
 0 & \bot & \top & \bot \\
 1 & \top & \bot & \top \\
 2 & \top & \bot & \top \\
\end{array}
$$

Since there is only one $\square$ in the formula, the chain is guaranteed to stabilize in the first world and there is no need for going further. We have shown the truth values in world $2$ to show that this is indeed the case.

From the table we have just constructed it becomes evident that $[[p]]_{\neg\square p} = \mathbb{N}\setminus \{0\}$. Thus $H = \square^{0+1}\bot \wedge \square^0\bot = \neg\square\bot$.

Therefore, $GL\vdash \square [p\leftrightarrow \neg\square p]\leftrightarrow \square[p\leftrightarrow \neg\square \bot]$. Thus, the fixed point for the modal Gödel sentence is the [-5km] of arithmetic!

By employing the [ arithmetical soundness of GL], we can translate this result to $PA$ and show that $PA\vdash \square_{PA} [G\leftrightarrow \neg\square_{PA} G]\leftrightarrow \square_{PA}[G\leftrightarrow \neg\square_{PA} \bot]$ for every sentence $G$ of arithmetic.

Since in $PA$ we can construct $G$ by the [-59c] such that $PA\vdash G\leftrightarrow \neg\square_{PA} G$, by necessitation we have that for such a $G$ then $PA\vdash \square_PA[ G\leftrightarrow \neg\square_{PA} G]$. By the theorem we just proved using the fixed point, then $PA\vdash \square_{PA}[G\leftrightarrow \neg\square_{PA} \bot]$. SInce [ everything $PA$ proves is true] then $PA\vdash G\leftrightarrow \neg\square_{PA} \bot$.

Surprisingly enough, the Gödel sentence is equivalent to the consistency of arithmetic! This makes more evident that $G$ is not provable [godel_second_incompleteness_theorm unless $PA$ is inconsistent], and that it is not disprovable unless it is [omega_inconsistency $\omega$-inconsistent].

**Exercise:** Find the fixed point for the [ Henkin sentence] $H\leftrightarrow\square H$.

%%hidden(Show solution):
$$
\begin{array}{ccc}
 \text{world= } & p & \square (p) \\
 0 & \top & \top \\
 1 & \top & \top \\
\end{array}
$$
Thus the fixed point is simply $\top$.
%%

#General case
The first generalization we make to the theorem is allowing the appearance of sentence letters other than the one we are fixing. The concrete statement is as follows:

>Let $\phi(p, q_1,...,q_n)$ be a modal sentence [5m4 modalized] in p. Then $\phi$ has a fixed point on $p$.%%.

There are several constructive procedures for finding the fixed point in the general case.

One particularly simple procedure is based on **k-decomposition**.

##K-decomposition
Let $\phi$ be as in the hypothesis of the fixed point theorem. Then we can express $\phi$ as $B(\square D_1(p), ..., \square D_{k}(p))$, since every $p$ occurs within the scope of a $\square$ (The $q_i$s are omitted for simplicity, but they may appear scattered between $B$ and the $D_i$s). This is called a $k$-decomposition of $\phi$.

If $\phi$ is $0$-decomposable, then it is already a fixed point, since $p$ does not appear.

Otherwise, consider $B_i = B(\square D_1(p), ..., \square D_{i-1}(p),\top, \square D_{i+1}(p),...,\square D_k(p))$, which is $k-1$-decomposable.

Assuming that the procedure works for $k-1$ decomposable formulas, we can use it to compute a fixed point $H_i$ for each $B_i$. Now, $H=B(\square D_1(H_1),...,\square D_k(H_k))$ is the desired fixed point for $\phi$.

%%hidden(Proof):
[todo: proof]
There is a nice semantic proof in *Computability and Logic*, by Boolos *et al*.
%%

This procedure constructs fixed points with structural similarity to the original sentence.

###Example
Let's compute the fixed point of $p\leftrightarrow \neg\square(q\to p)$.

We can 1-decompose the formula in $B(d)=\neg d$, $D_1(p)=q\to p$.

Then $B_1(p)=\neg \top = \bot$, which is its own fixed point. Thus the desired fixed point is $H=B(\square D_1(\bot))=\neg\square \neg q$.

**Exercise:** Compute the fixed point of $p\leftrightarrow \square [\square(p\wedge q)\wedge \square(p\wedge r)]$.

%%hidden(Show solution):
One possible decomposition of the the formula at hand is $B(a)=a$, $D_1(p)=\square(p\wedge q)\wedge \square(p\wedge r)$.

Now we compute the fixed point of $B(\top)$, which is simply $\top$.

Therefore the fixed point of the whole expression is $B(\square D_1(p=\top))=\square[\square(\top\wedge q)\wedge \square(\top\wedge r)]=\square[\square(q)\wedge \square(r)]$
%%

#Generalized fixed point theorem

>Suppose that $A_i(p_1,...,p_n)$ are $n$ modal sentences such that $A_i$ is modalized in $p_n$ (possibly containing sentence letters other than $p_js$).

>Then there exists $H_1, ...,H_n$ in which no $p_j$ appears such that $GL\vdash \wedge_{i\le n} \{\boxdot (p_i\leftrightarrow A_i(p_1,...,p_n)\}\leftrightarrow \wedge_{i\le n} \{\boxdot(p_i\leftrightarrow H_i)\}$.

%%hidden(Proof):
We will prove it by induction.

For the base step, we know by the fixed point theorem that there is $H$ such that $GL\vdash \boxdot(p_1\leftrightarrow A_i(p_1,...,p_n)) \leftrightarrow \boxdot(p_1\leftrightarrow H(p_2,...,p_n))$

Now suppose that for $j$ we have $H_1,...,H_j$ such that $GL\vdash \wedge_{i\le j} \{\boxdot(p_i\leftrightarrow A_i(p_1,...,p_n)\}\leftrightarrow \wedge_{i\le j} \{\boxdot(p_i\leftrightarrow H_i(p_{j+1},...,p_n))\}$.

By the [ second substitution theorem], $GL\vdash \boxdot(A\leftrightarrow B)\rightarrow [F(A)\leftrightarrow F(B)]$. Therefore we have that $GL\vdash \boxdot(p_i\leftrightarrow H_i(p_{j+1},...,p_n)\rightarrow [\boxdot(p_{j+1}\leftrightarrow A_{j+1}(p_{1},...,p_n))\leftrightarrow \boxdot(p_{j+1}\leftrightarrow A_{j+1}(p_{1},...,p_{i-1},H_i(p_{j+1},...,p_n),p_{i+1},...,p_n))]$.

If we iterate the replacements, we finally end up with $GL\vdash \wedge_{i\le j} \{\boxdot(p_i\leftrightarrow A_i(p_1,...,p_n)\}\rightarrow \boxdot(p_{j+1}\leftrightarrow A_{j+1}(H_1,...,H_j,p_{j+1},...,p_n))$.

Again by the fixed point theorem, there is $H_{j+1}'$ such that $GL\vdash \boxdot(p_{j+1}\leftrightarrow A_{j+1}(H_1,...,H_j,p_{j+1},...,p_n)) \leftrightarrow \boxdot[p_{j+1}\leftrightarrow H_{j+1}'(p_{j+2},...,p_n)]$.

But as before, by the second substitution theorem, $GL\vdash \boxdot[p_{j+1}\leftrightarrow H_{j+1}'(p_{j+2},...,p_n)]\rightarrow [\boxdot(p_i\leftrightarrow H_i(p_{j+1},...,p_n)) \leftrightarrow \boxdot(p_i\leftrightarrow H_i(H_{j+1}',...,p_n))$.

Let $H_{i}'$ stand for $H_i(H_{j+1}',...,p_n)$, and by combining the previous lines we find that $GL\vdash \wedge_{i\le j+1} \{\boxdot(p_i\leftrightarrow A_i(p_1,...,p_n)\}\rightarrow \wedge_{i\le j+1} \{\boxdot(p_i\leftrightarrow H_i'(p_{j+2},...,p_n))\}$.

By [ Goldfarb's lemma], we do not need to check the other direction, so $GL\vdash \wedge_{i\le j+1} \{\boxdot(p_i\leftrightarrow A_i(p_1,...,p_n)\}\leftrightarrow \wedge_{i\le j+1} \{\boxdot(p_i\leftrightarrow H_i'(p_{j+2},...,p_n))\}$ and the proof is finished $\square$

----

One remark: the proof is wholly constructive. You can iterate the construction of fixed point following the procedure implied by the construction of the $H_i'$ to compute fixed points.

%%

An immediate consequence of the theorem is that for those fixed points $H_i$ and every $A_i$, $GL\vdash H_i\leftrightarrow A_i(H_1,...,H_n)$.

Indeed, since $GL$ is closed under substitution, we can make the change $p_i$ for $H_i$ in the theorem to get that $GL\vdash \wedge_{i\le n} \{\boxdot (H_i\leftrightarrow A_i(H_1,...,H_n)\}\leftrightarrow \wedge_{i\le n} \{\boxdot(H_i\leftrightarrow H_i)\}$.

Since the righthand side is trivially a theorem of $GL$, we get the desired result.


Irreducible element (ring theory)

[summary: An irreducible element of a [3gq ring] is one which cannot be written as a nontrivial product of two other elements of the ring.]

[summary(Technical): Let $(R, +, 	imes)$ be a [3gq ring] which is an [5md integral domain]. We say $x \in R$ is *irreducible* if, whenever we write $r = a 	imes b$, it is the case that (at least) one of $a$ or $b$ is a [5mg unit] (that is, has a multiplicative inverse).]

[3gq Ring theory] can be viewed as the art of taking the integers [48l $\mathbb{Z}$] and extracting or identifying its essential properties, seeing where they lead.
In that light, we might ask what the abstracted notion of "[4mf prime]" should be.
Confusingly, we call this property *irreducibility* rather than "primality"; "[5m2 prime]" in ring theory corresponds to something closely related but not the same.

In a ring $R$ which is an [-5md], we say that an element $x \in R$ is *irreducible* if, whenever we write $r = a 	imes b$, it is the case that (at least) one of $a$ or $b$ is a [5mg unit] (that is, has a multiplicative inverse).

# Why do we require $R$ to be an integral domain?
[todo: this]

# Examples
[todo: lots]

# Relationship with primality in the ring-theoretic sense

It is always the case that [5m2 primes] are irreducible in any integral domain.
%%hidden(Show proof):
If $p$ is prime, then $p \mid ab$ implies $p \mid a$ or $p \mid b$ by definition.
We wish to show that if $p=ab$ then one of $a$ or $b$ is invertible.

Suppose $p = ab$.
Then in particular $p \mid ab$ so $p \mid a$ or $p \mid b$.
Assume without loss of generality that $p \mid a$; so there is some $c$ such that $a = cp$.

Therefore $p = ab = cpb$; we are working in a commutative ring, so $p(1-bc) = 0$.
Since the ring is an integral domain and $p$ is prime (so is nonzero), we must have $1-bc = 0$ and hence $bc = 1$.
That is, $b$ is invertible.
%%

However, the converse does not hold (though it may in certain rings).

- In $\mathbb{Z}$, it is a fact that irreducibles are prime. Indeed, it is a consequence of [5mp Bézout's theorem] that if $p$ is "prime" in the usual $\mathbb{Z}$-sense (that is, irreducible in the rings sense) %%note:I'm sorry about the notation. It's just what we're stuck with. It is very confusing.%%, then $p$ is "prime" in the rings sense. ([5mh Proof.])
- In the ring $\mathbb{Z}[\sqrt{-3}]$ of [4zw complex numbers] of the form $a+b \sqrt{-3}$ where $a, b$ are integers, the number $2$ is irreducible but we may express $4 = 2 	imes 2 = (1+\sqrt{-3})(1-\sqrt{-3})$. That is, we have $2 \mid (1+\sqrt{-3})(1-\sqrt{-3})$ but $2$ doesn't divide either of those factors. Hence $2$ is not prime.

%%hidden(Proof that $2$ is irreducible in $\mathbb{Z}[\sqrt{-3}]):
A slick way to do this goes via the [norm_complex_number norm] $N(2)$ of the complex number $2$; namely $4$.

If $2 = ab$ then $N(2) = N(a)N(b)$ because [norm_of_complex_number_is_multiplicative the norm is a multiplicative function], and so $N(a) N(b) = 4$.
But $N(x + y \sqrt{-3}) = x^2 + 3 y^2$ is an integer for any element of the ring, and so we have just two distinct options: $N(a) = 1, N(b) = 4$ or $N(a) = 2 = N(b)$.
(The other cases follow by interchanging $a$ and $b$.)

The first case: $N(x+y \sqrt{3}) = 1$ is only possible if $x= \pm 1, y = \pm 0$.
Hence the first case arises only from $a=\pm1, b=\pm2$; this has not led to any new factorisation of $2$.

The second case: $N(x+y \sqrt{3}) = 2$ is never possible at all, since if $y
ot = 0$ then the norm is too big, while if $y = 0$ then we are reduced to finding $x \in \mathbb{Z}$ such that $x^2 = 2$.

Hence if we write $2$ as a product, then one of the factors must be invertible (indeed, must be $\pm 1$).
%%

In fact, in a [-principal_ideal_domain], "prime" and "irreducible" are equivalent. ([5mf Proof.])

# Relationship with unique factorisation domains

It is a fact that an integral domain $R$ is a [unique_factorisation_domain UFD] if and only if it has "all irreducibles are [5m2 prime] (in the sense of ring theory)" and "every $r \in R$ may be written as a product of irreducibles". ([alternative_condition_for_ufd Proof.])
This is a slightly easier condition to check than our original definition of a UFD, which instead of "all irreducibles are prime" had "products are unique up to reordering and multiplying by invertible elements".

Therefore the relationship between irreducibles and primes is at the heart of the nature of a unique factorisation domain.
Since $\mathbb{Z}$ is a UFD, in some sense the [fundamental_theorem_of_arithmetic Fundamental Theorem of Arithmetic] holds precisely because of the fact that "prime" is the same as "irreducible" in $\mathbb{Z}$.


Prime element of a ring

[summary:  A prime element of a [3gq ring] is one such that, if it divides a product, then it divides (at least) one of the terms of the product.]

[summary(Technical): Let $(R, +, 	imes)$ be a [3gq ring] which is an [5md integral domain]. We say $p \in R$ is *prime* if, whenever $p \mid ab$, it is the case that either $p \mid a$ or $p \mid b$ (or both).]

An element of an [-5md] is *prime* if it has the property that $p \mid ab$ implies $p \mid a$ or $p \mid b$.
Equivalently, if its generated [ideal_ring_theory ideal] is [prime_ideal prime] in the sense that $ab \in \langle p
angle$ implies either $a$ or $b$ is in $\langle p
angle$.

Be aware that "prime" in ring theory does not correspond exactly to "[4mf prime]" in number theory (the correct abstraction of which is [5m1 irreducibility]).
It is the case that they are the same concept in the ring $\mathbb{Z}$ of [48l integers] ([5mf proof]), but this is a nontrivial property that turns out to be equivalent to the [-5rh] ([alternative_condition_for_ufd proof]).

# Examples

# Properties

- Primes are always [5m1 irreducible]; a proof of this fact appears on the [5m1 page on irreducibility], along with counterexamples to the converse.
-


Modalized modal sentence

A [ modal sentence] $A$ is said to be **modalized** in $p$ if every occurrence of $p$ happens within the scope of a $\square$.

As an example, $\square p \wedge q$ is modalized in $p$, but not in $q$.

If $A$ does not contain $p$, then it is trivially modalized in $p$.

A sentence which is modalized in every sentence letter is said to be **fully modalized**.

Being modalized in $p$ is a sufficient condition for having a [5lx fixed point] on $p$.


Integral domain

[summary: An integral domain is a [3gq ring] in which the only way to make $0$ as a product is to multiply $0$ by something. For instance, in an integral domain like [48l $\mathbb{Z}$], $2 	imes 3$ is not equal to $0$ because neither $2$ nor $3$ is.]

[summary(Technical): An integral domain is a [3gq ring] in which $ab=0$ implies $a=0$ or $b=0$. (We exclude the ring with one element: that is conventionally not considered an integral domain.)]

In keeping with [3gq ring theory] as the attempt to isolate each individual property of [48l $\mathbb{Z}$] and work out how the properties interplay with each other, we define the notion of **integral domain** to capture the fact that if $a 	imes b = 0$ then $a=0$ or $b=0$.
That is, an integral domain is one which has no "zero divisors": $0$ cannot be nontrivially expressed as a product.
(For uninteresting reasons, we also exclude the ring with one element, in which $0=1$, from being an integral domain.)

# Examples

- $\mathbb{Z}$ is an integral domain.
- Any [481 field] is an integral domain. (The proof is an exercise.)

%%hidden(Show solution):
Suppose $ab = 0$, but $a
ot = 0$. We wish to show that $b=0$.

Since we are working in a field, $a$ has an inverse $a^{-1}$; multiply both sides by $a^{-1}$ to obtain $a^{-1} a b = 0 	imes a^{-1}$.
Simplifying, we obtain $b = 0$.
%%

- When $p$ is a [4mf prime] integer, the ring $\mathbb{Z}_p$ of integers [modular_arithmetic mod] $p$ is an integral domain.
- When $n$ is a [composite_number composite] integer, the ring $\mathbb{Z}_n$ is *not* an integral domain. Indeed, if $n = r 	imes s$ with $r, s$ positive integers, then $r s = n = 0$ in $\mathbb{Z}_n$.

# Properties

The reason we care about integral domains is because they are precisely the rings in which we may cancel products: if $a
ot = 0$ and $ab = ac$ then $b=c$.
%%hidden(Proof):
Indeed, if $ab = ac$ then $ab-ac = 0$ so $a(b-c) = 0$, and hence (in an integral domain) $a=0$ or $b=c$.

Moreover, if we are not in an integral domain, say $r s = 0$ but $r, s
ot = 0$.
Then $rs = r 	imes 0$, but $s
ot = 0$, so we can't cancel the $r$ from both sides.
%%

## Finite integral domains

If a ring $R$ is both finite and an integral domain, then it is a [481 field].
The proof is an exercise.
%%hidden(Show solution):
Given $r \in R$, we wish to find a multiplicative inverse.

Since there are only finitely many elements of the ring, consider $S = \{ ar : a \in R\}$.
This set is a subset of $R$, because the multiplication of $R$ is [3gy closed].
Moreover, every element is distinct, because if $ar = br$ then we can cancel the $r$ (because we are in an integral domain), so $a = b$.

Since there are $|R|$-many elements of the subset $S$ (where $| \cdot |$ refers to the [-4w5]), and since $R$ is finite, $S$ must in fact be $R$ itself.

Therefore in particular $1 \in S$, so $1 = ar$ for some $a$.
%%


In a principal ideal domain, "prime" and "irreducible" are the same

[summary: While there are two distinct but closely related notions of "[5m2 prime]" and "[5m1 irreducible]", the two ideas are actually the same in a certain class of [3gq ring]. This result is basically what enables the [-fundamental_theorem_of_arithmetic].]

Let $R$ be a [3gq ring] which is a [principal_ideal_domain PID], and let $r
ot = 0$ be an element of $R$.
Then $r$ is [5m1 irreducible] if and only if $r$ is [5m2 prime].

In fact, it is easier to prove a stronger statement: that the following are equivalent.
%%note:Every proof known to the author is of this shape either implicitly or explicitly, but when it's explicit, it should be clearer what is going on.%%

1. $r$ is irreducible.
2. $r$ is prime.
3. The generated [ideal_ring_theory ideal] $\langle r
angle$ is [maximal_ideal maximal] in $R$.

[todo: motivate the third bullet point]

# Proof

## $2 \Rightarrow 1$
A proof that "prime implies irreducible" appears on the page for [5m1 irreducibility].

## $3 \Rightarrow 2$
We wish to show that if $\langle r
angle$ is maximal, then it is prime.
(Indeed, $r$ is [5m2 prime] if and only if its generated ideal is [prime_ideal prime].)

An ideal $I$ is maximal if and only if the [quotient_ring quotient] $R/I$ is a [481 field]. ([ideal_maximal_iff_quotient_is_field Proof.])

An ideal $I$ is [prime_ideal prime] if and only if the quotient $R/I$ is an [-5md]. ([ideal_prime_iff_quotient_is_integral_domain Proof.])

All fields are integral domains. (A proof of this appears on [5md the page on integral domains].)

Hence maximal ideals are prime.

## $1 \Rightarrow 3$
Let $r$ be irreducible; then in particular it is not invertible, so $\langle r
angle$ isn't simply the whole ring.

To show that $\langle r
angle$ is maximal, we need to show that if it is contained in any larger ideal then that ideal is the whole ring.

Suppose $\langle r
angle$ is contained in the larger ideal $J$, then.
Because we are in a principal ideal domain, $J = \langle a
angle$, say, for some $a$, and so $r = a c$ for some $c$.
It will be enough to show that $a$ is invertible, because then $\langle a
angle$ would be the entire ring.

But $r$ is irreducible, so one of $a$ and $c$ is invertible; if $a$ is invertible then we are done, so suppose $c$ is invertible.

Then $a = r c^{-1}$.
We have supposed that $J$ is indeed larger than $\langle r
angle$: that there is $j \in J$ which is not in $\langle r
angle$.
Since $j \in J = \langle a
angle$, we can find $d$ (say) such that $j = a d$; so $j = r c^{-1} d$ and hence $j \in \langle r
angle$, which is a contradiction.


Unit (ring theory)

[summary: A unit of a [3gq ring] is an element with a multiplicative inverse.]

An element $x$ of a non-trivial [3gq ring]%%note:That is, a ring in which $0
ot = 1$; equivalently, a ring with more than one element.%% is known as a **unit** if it has a multiplicative inverse: that is, if there is $y$ such that $xy = 1$.
(We specified that the ring be non-trivial.
If the ring is trivial then $0=1$ and so the requirement is the same as $xy = 0$; this means $0$ is actually invertible in this ring, since its inverse is $0$: we have $0 	imes 0 = 0 = 1$.)

$0$ is never a unit, because $0 	imes y = 0$ is never equal to $1$ for any $y$ (since we specified that the ring be non-trivial).

If every nonzero element of a ring is a unit, then we say the ring is a [481 field].

Note that if $x$ is a unit, then it has a *unique* inverse; the proof is an exercise.
%%hidden(Proof):
If $xy = xz = 1$, then $zxy = z$ (by multiplying both sides of $xy=1$ by $z$) and so $y = z$ (by using $zx = 1$).
%%

# Examples

- In [48l $\mathbb{Z}$], $1$ and $-1$ are both units, since $1 	imes 1 = 1$ and $-1 	imes -1 = 1$. However, $2$ is not a unit, since there is no integer $x$ such that $2x=1$. In fact, the *only* units are $\pm 1$.
- [4zq $\mathbb{Q}$] is a [481 field], so every rational except $0$ is a unit.


Euclid's Lemma on prime numbers

[summary: The [4mf prime numbers] have a special property that they "can't be distributed between terms of a product": if $p$ is a prime dividing a product $ab$ of [48l integers], then $p$ wholly divides one or both of $a$ or $b$. It cannot be the case that "some but not all of $p$ divides into $a$, and the rest of $p$ divides into $b$".]

[summary(Technical): Let $p$ be a [4mf prime] natural number. Then $p \mid ab$ implies $p \mid a$ or $p \mid b$.]

Euclid's lemma states that if $p$ is a [4mf prime number], which divides a product $ab$, then $p$ divides at least one of $a$ or $b$.

# Proof

## Elementary proof

Suppose $p \mid ab$ %%note:That is, $p$ divides $ab$.%%, but $p$ does not divide $a$.
We will show that $p \mid b$.

Indeed, $p$ does not divide $a$, so the [-5mw] of $p$ and $a$ is $1$ (exercise: do this without using integer factorisation); so by [bezouts_theorem Bézout's theorem] there are integers $x, y$ such that $ax+py = 1$.

%%hidden(Show solution to exercise):
We are not allowed to use the fact that we can factorise integers, because we need "$p \mid ab$ implies $p \mid a$ or $p \mid b$" as a lemma on the way towards the proof of the [-5rh] (which is the theorem that tells us we can factorise integers).

Recall that the highest common factor of $a$ and $p$ is defined to be the number $c$ such that:

- $c \mid a$;
- $c \mid p$;
- for any $d$ which divides $a$ and $p$, we have $d \mid c$.

[euclidean_algorithm Euclid's algorithm] tells us that $a$ and $p$ do have a (unique) highest common factor.

Now, if $c \mid p$, we have that $c = p$ or $c=1$, because $p$ is [4mf prime].
But $c$ is not $p$ because we also know that $c \mid a$, and we already know $p$ does not divide $a$.

Hence $c = 1$.
%%

But multiplying through by $b$, we see $abx + pby = b$.
$p$ divides $ab$ and divides $p$, so it divides the left-hand side; hence it must divide the right-hand side too.
That is, $p \mid b$.

## More abstract proof

This proof uses much more theory but is correspondingly much more general, and it reveals the important feature of $\mathbb{Z}$ here.

$\mathbb{Z}$, viewed as a [3gq ring], is a [-5r5]. ([integers_is_pid Proof.])
The theorem we are trying to prove is that the [5m1 irreducibles] in $\mathbb{Z}$ are all [5m2 prime] in the sense of ring theory.

But it is generally true that in a PID, "prime" and "irreducible" coincide ([5mf proof]), so the result is immediate.

# Converse is false

Any composite number $pq$ (where $p, q$ are greater than $1$) divides $pq$ without dividing $p$ or $q$, so the converse is very false.

# Why is this important?

This lemma is a nontrivial step on the way to proving the [-5rh]; and in fact in a certain general sense, if we can prove this lemma then we can prove the FTA.
It tells us about the behaviour of the primes with respect to products: we now know that the primes "cannot be split up between factors" of a product, and so they behave, in a sense, [5m1 "irreducibly"].

The lemma is also of considerable use as a tiny step in many different proofs.


Bézout's theorem

[summary: Bézout's theorem states that if $a$ and $b$ are integers, and $c$ is an integer, then the equation $ax+by = c$ has integer solutions in $x$ and $y$ if and only if the [-5mw] of $a$ and $b$ divides $c$.]

Bézout's theorem is an important basic theorem of number theory.
It states that if $a$ and $b$ are integers, and $c$ is an integer, then the equation $ax+by = c$ has integer solutions in $x$ and $y$ if and only if the [-5mw] of $a$ and $b$ divides $c$.

# Proof

We have two directions of the equivalence to prove.

## If $ax+by=c$ has solutions

Suppose $ax+by=c$ has solutions in $x$ and $y$.
Then the highest common factor of $a$ and $b$ divides $a$ and $b$, so it divides $ax$ and $by$; hence it divides their sum, and hence $c$.

## If the highest common factor divides $c$

Suppose $\mathrm{hcf}(a,b) \mid c$; equivalently, there is some $d$ such that $d 	imes \mathrm{hcf}(a,b) = c$.

We have the following fact: that the highest common factor is a linear combination of $a, b$. ([hcf_is_linear_combination Proof]; this [extended_euclidean_algorithm can also be seen] by working through [euclidean_algorithm Euclid's algorithm].)

Therefore there are $x$ and $y$ such that $ax + by = \mathrm{hcf}(a,b)$.

Finally, $a (xd) + b (yd) = d \mathrm{hcf}(a, b) = c$, as required.

# Actually finding the solutions

Suppose $d 	imes \mathrm{hcf}(a,b) = c$, as above.

The [-extended_euclidean_algorithm] can be used (efficiently!) to obtain a linear combination $ax+by$ of $a$ and $b$ which equals $\mathrm{hcf}(a,b)$.
Once we have found such a linear combination, the solutions to the integer equation $ax+by=c$ follow quickly by just multiplying through by $d$.

# Importance

Bézout's theorem is important as a step towards the proof of [5mh Euclid's lemma], which itself is the key behind the [5rh].
It also holds in general [5r5 principal ideal domains].


Rice's Theorem

[summary: Rice's Theorem tells us that for *every* nontrivial property of computable functions, there is no general procedure which takes as its input a Turing machine, and computes whether or not the function computed by that machine has that property. That is, there is no general way to determine anything nontrivial about the output of an arbitrary Turing machine.]

Rice's Theorem is a rather surprising and very strong restriction on what we can determine about the [-3jy] computed by an arbitrary [5pd Turing machine].
It tells us that for *every* nontrivial property of computable functions %%note:By "nontrivial", we mean there is at least one function with that property and at least one without that property.%%, there is no general procedure which takes as its input a Turing machine, and computes whether or not the function computed by that machine has that property.

Therefore, if we want to discover anything about the output of a general computer program, *in general* the best we can do is simply run the program.
As a corollary, there can be no *fully general* procedure that checks whether a piece of computer code is free of bugs or not.

# Formal statement

We will use the notation $[n]$ for the $n$th [5pd Turing machine] under some fixed [description_number numbering system].
Each such machine induces a [-5p2], which we will also write as $[n]$ where this is unambiguous due to context; then it makes sense to write $[n](m)$ for the value that machine $[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_of_a_function graph] of the [-5p2] computed by $[n]$, the $n$th Turing machine.
Then there is no Turing machine $[r]$ such that:

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

# Caveats

- While this result tells us, for example, that "no procedure will ever be able to determine whether an arbitrary program is bug-free", in practice it may be possible to determine whether *a large class* of programs is bug-free, while accepting the fact that our procedure might not be able to solve the fully general case.

- Additionally, this result only tells us about the *graphs* of the functions in question.
We can determine certain properties which are specific to the Turing machine: for example, we can tell whether the program will halt in five steps, by simply running it for five steps.
This does not contradict Rice, because Rice tells us only about the ultimate answer the machines spit out, and nothing about the procedures they use to get to the answer; "the machine halts in five steps" is not a property of the graph of the function, but is a property of the Turing machine itself.

- Rice's theorem is only a restriction on whether we can *decide* the status of a function: that is, whether we can decide *whether or not* the function computed by some machine has a certain property. Rice tells us nothing if we're only looking for a procedure that "must find out in finite time whether a function *does* have a property, but is allowed to never give an answer if the function *doesn't* have the property".
For example, we can determine whether a partial function is defined anywhere (that is, it is not the empty function: the one which never outputs anything, whatever its input) by just attempting to evaluate the function in parallel at $0$, at $1$, at $2$, and so on.
If the partial function is defined anywhere, then eventually one of the parallel threads will discover this fact; but if it is defined nowhere, then the procedure might just spin on and on forever without giving any output.
However, Rice's theorem does guarantee that there is no procedure which will tell us in finite time *whether or not* its input is a function which is defined somewhere; even though we have just specified a procedure which will tell us in finite time *if* its input is defined somewhere.

# Proof outline

Several proofs exist: for example, [5n6 one by reduction] to the [halting_problem halting problem], and one [5t9 standalone proof].
Here, we sketch the standalone proof in broad strokes, because it goes via a neat lemma.

The intermediate lemma we prove is:

> Let $h: \mathbb{N} 	o \mathbb{N}$ be [total_function total] 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 $[n]$ - has the same output, at every point, as the function computed by $[h(n)]$.
If we view $h$ as a way of manipulating a program (as specified by its [-description_number]), then this fixed-point theorem states that we can find a program whose underlying function is not changed at all by $h$.

This lemma might be somewhat surprising: it "ought" to be possible to find a change one could make to arbitrary computer code, with the guarantee that the altered code must do something different to the original.
The fixed-point theorem tells us that this is not the case.

The proof of the lemma is very difficult to understand fully, but rather easy to state, because there are several useful shorthands which hide much of the complexity of what is really going on; full details, along with a worked example, can be found in [5t9 the accompanying lens].

Once we have the intermediate lemma, Rice's theorem itself follows quickly.
Indeed, if the operation of "determine whether a machine computes a function whose graph is in $A$ or not" is computable, then we can do the following procedure:

- Take some computer code as input.
- Determine whether the code specifies a function whose graph is in $A$ or not.
- If it is in $A$, output code for a specific (probably unrelated) function whose graph is *not* in $A$.
- Otherwise, output code for a specific (probably unrelated) function whose graph is in $A$.

The fixed-point theorem tells us that some program isn't changed by the above procedure; but the procedure is guaranteed to interchange programs-from-$A$ with programs-not-from-$A$, so the procedure can't have any fixed points after all.


Greatest common divisor

[summary: The greatest common divisor of two [45h natural numbers] is the largest number which divides both of them.]

There are two ways to define the **greatest common divisor** (also known as **greatest common factor**, or **highest common factor**), both equivalent.

The first definition is as the name suggests: the GCD of $a$ and $b$ is the largest number which divides both $a$ and $b$.

The second definition is the more "mathematical", because it generalises to arbitrary [3gq rings] rather than just [55j ordered rings].
The GCD of $a$ and $b$ is the number $c$ such that $c \mid a$, $c \mid b$, and whenever $d \mid a$ and $d \mid b$, we have $d \mid c$.
(That is, it is the maximal element of the [-3rb] that consists of the divisors of $a$ and $b$, ordered by division.)

# Examples

[todo: show the two different definitions in action and how they prepare]

# Equivalence of the definitions

[todo: prove this]

# Relation to prime factorisations

[todo: algorithm given access to prime factorisations; explain why this is unhelpful]

# Calculating the GCD efficiently

[todo: link to Euclidean algorithm]


Metric

[summary:
Let $S$ be a set. A **metric** on $S$ is a function $d : S 	imes S 	o \mathbb R_{\ge 0}$ such that for all $a,b,c \in S$,

1. $d(a,b) = 0 \Leftrightarrow a = b$
2. $d(a,b) = d(b,a)$
3. $d(a,b) + d(b,c) \geq d(a,c)$

Such a function defines a notion of distance between pairs of elements of $S$.
]

A **metric**, sometimes referred to as a distance function, is a [-3jy] that defines a [-4bc real] nonnegative distance between every two elements of a [3jz set]. It is commonly denoted by the variable $d$. In [-3vl], a metric $d$ that defines distances between elements of the set $S$ is written:
$$d: S 	imes S 	o [0, \infty)$$

In this case we say $d$ *is a metric on* $S$.

That is, a metric $d$ on a set $S$ takes as input any two elements $a$ and $b$ from $S$ and outputs a number that is taken to define their distance in $S$ under $d$. Apart from being nonnegative real numbers, the distances a metric outputs must follow three other rules in order for the function to meet the definition of a metric. A function that matches the above colon-to notation is called a metric if and only if it satisfies these requirements. The following must hold for any choice of $a$, $b$, and $c$ in $S$:

 1. $d(a, b) = 0 \iff a = b$

 2. $d(a, b) = d(b, a)$

 3. $d(a, b) + d(b, c) \geq d(a, c)$

(1) effectively states both that the distance from an element to itself is 0, and that the distance between non-identical elements must be greater than 0. (2) asserts that a metric must be [3jb commutative]; informally the distance from $a$ to $b$ must be the same as the distance from $b$ to $a$. Finally, (3) is known as the [-triangle_inequality] and asserts that the distance from $a$ to $c$ is at most as large as the sum of the distances from $a$ to $b$ and from $b$ to $c$. It is named as such because in [euclidean_space], the points $a$, $b$, and $c$ form a triangle, and the inequality requires that the length of one side of the triangle is not longer than the sum of the lengths of the other two sides; violating this would mean that the shortest path between two points is no longer the straight line between them.

It is possible (and relatively common!) to deal with multiple different metrics on the same set. This means we are using the same set elements as labels, but treating the distances between elements differently; in this case the different [metric_space metric spaces] we are defining may have very different properties. If multiple metrics are being considered, we must be careful when speaking of distances between elements of the set to specify which metric we are using. For example, if $d$ and $e$ are both metrics on $S$, we cannot just say "the distance between $a$ and $b$ in $S$" because it is ambiguous whether we are referring to $d(a, b)$ or to $e(a, b)$. We could instead say something like "the distance between $a$ and $b$ under $e$" to remove the ambiguity.

The most commonly-used metric on Cartesian space is the Euclidean metric, defined in two dimensions as $d(a, b) = \sqrt{(a_1-b_1)^2 + (a_2-b_2)^2}$, and more generally in $n$ dimensions as $d(a, b) = \sqrt{\sum_{i=1}^n (a_i-b_i)^2}$.

A less-common metric on Cartesian space is the Manhattan metric, defined generally as $d(a, b) = \sum_{i=1}^n |a_i-b_i|$; the distance is analogous to the distance taken between two points on a rectangular grid when motion is constrained to be purely vertical or horizontal, but not diagonal.

[todo: A metric induces a topology]
[todo: add intuitive/nonalgebraic explanation lens]
[todo: proof that Euclidean and Manhattan distances are metrics]