# Commutative Algebra/Objects and morphisms
## Basics

Definition 1.1 (categories):
A category ${\mathcal {C}}$ is a collection of objects together with morphisms, which go from an object $a\in {\mathcal {C}}$ to an object $b\in {\mathcal {C}}$ each (where $a$ is called the domain and $b$ the codomain), such that
* Any morphism $f:a\to b$ can be composed with a morphism $g:b\to c$ such that the composition of the two is a morphism $g\circ f:a\to c$.
* For each $a\in {\mathcal {C}}$, there exists a morphism $1_{a}:a\to a$ such that for any morphism $f:a\to b$ we have $f\circ 1_{a}=f$ and for any morphism $g:b\to a$ we have $1_{a}\circ g=g$.
Examples 1.2:
* The collection of all groups together with group homomorphisms as morphisms is a category.
* The collection of all rings together with ring homomorphisms is a category.
* Sets together with ordinary functions form the category of sets.
To every category we may associate an opposite category:
Definition 1.3 (opposite categories):
Let ${\mathcal {C}}$ be a category. The opposite category of ${\mathcal {C}}$ is the category consisting of the objects of ${\mathcal {C}}$, but all morphisms are considered to be inverted, which is done by simply define codomains to be the domain of the former morphism and domains to be codomains of former morphisms.
For instance, within the opposite category of sets, a function $f:S\to T$ (where $S$, $T$ are sets) is a morphism $T\to S$.

## Algebraic objects within category theory

A category is such a general object that some important algebraic structures arise as special cases. For instance, consider a category with one object. Then this category is a monoid with composition as its operation. On the other hand, if we are given an arbitrary monoid, we can define the elements of that monoid to be the morphisms from a single object to itself, and thus have found a representation of that monoid as a category with one object.
If we are given a category with one object, and the morphisms all happen to be invertible, then we have in fact a group structure. And further, just as described for monoids, we can turn every group into a category.

## Special types of morphisms

The following notions in category may have been inspired by stuff that happens within the category of sets and similar categories.
In the category of sets, we have surjective functions and injective functions. We may characterise those as follows:
Theorem 1.4:
Let $X,Y$ be sets and $f:X\to Y$ be a function. Then:
* $f$ is surjective if and only if for all sets $Z$ and functions $g,h:Y\to Z$ $g\circ f=h\circ f$ implies $g=h$.
* $f$ is injective iff for all sets $W$ and functions $g,h:W\to X$ $f\circ g=f\circ h$ implies $g=h$.
Proof:
We begin with the characterisation of surjectivity.
$\Rightarrow$: Let $f$ be surjective, and let $g\circ f=h\circ f$. Let $y\in Y$ be arbitrary. Since $f$ is surjective, we may choose $x\in X$ such that $f(x)=y$. Then we have $g(y)=g(f(x))=h(f(x))=h(y)$. Since $y\in Y$ was arbitrary, $g=h$.
$\Leftarrow$: Assume that for all sets $Z$ and functions $g,h:Y\to Z$ $g\circ f=h\circ f$ implies $g=h$. Assume for contradiction that $f$ isn't surjective. Then there exists $y_{0}\in Y$ outside the image of $f$. Let $Z=\{1,2\}$. We define $g,h:Y\to Z$ as follows:
    $g(y)=1\forall y\in Y$, $h(y)={\begin{cases}1&y\neq y_{0}\\2&y=y_{0}\end{cases}}$.
Then $g\circ f=h\circ f=1$ (since $y_{0}$, the only place where the second function might be $2$, is never hit by $f$), but $g\neq h$.
Now we prove the characterisation of injectivity.
$\Rightarrow$: Let $f$ be injective, let $W$ be another set and let $g,h:W\to X$ be two functions such that $f\circ g=f\circ h$. Assume that $g(w)\neq h(w)$ for a certain $w\in W$. Then $f(g(w))\neq f(h(w))$ due to the injectivity of $f$, contradiction.
$\Leftarrow$: Assume that for all sets $W$ and functions $g,h:W\to X$ $f\circ g=f\circ h$ implies $g=h$. Let $x,y\in X$ be arbitrary such that $f(x)=f(y)$. Take $W=\{1\}$ and $g(1)=x,h(1)=y$. Then $x=y$ and hence surjectivity.$\Box$
It is interesting that the change from injectivity and surjectivity swapped the use of indirect proof from the $\Leftarrow$-direction to the $\Rightarrow$-direction.
Since in the characterisation of injectivity and surjectivity given by the last theorem there is no mention of elements of sets any more, we may generalise those concepts to category theory.
Definition 1.5:
Let ${\mathcal {C}}$ be a category, and let $f$ be a morphism of ${\mathcal {C}}$. We say that
* $f:X\to Y$ is an epimorphism if and only if for all objects $Z$ of ${\mathcal {C}}$ and all morphisms $g,h:Y\to Z$ $g\circ f=h\circ f\Rightarrow g=h$, and
* $f:X\to Y$ is a monomorphism if and only if for all objects $W$ of ${\mathcal {C}}$ and all morphisms $g,h:W\to X$ $f\circ g=f\circ h\Rightarrow g=h$.

### Exercises

* Exercise 1.3.1: Come up with a category ${\mathcal {C}}$, where the objects are some finitely many sets, such that there exists an epimorphism that is not surjective, and a monomorphism that is not injective (Hint: Include few morphisms).

## Terminal, initial and zero objects and zero morphisms

Within many categories, such as groups, rings, modules,... (but not fields), there exist some sort of "trivial" objects which are the simplest possible; for instance, in the category of groups, there is the trivial group, consisting only of the identity. Indeed, within the category of groups, the trivial group has the following property:
Theorem 1.6:
Let $|G|=1$ and let $H$ be another group. Then there exists exactly one homomorphism $f:H\to G$ and exactly one homomorphism $g:G\to H$.
Futhermore, if ${\tilde {G}}$ is any other group with the property that for every other group $H$, there exists exactly one homomorphism ${\tilde {G}}\to H$ and exactly one homomorphism $H\to {\tilde {G}}$, then $|{\tilde {G}}|=1$.
Proof: We begin with the first part. Let $f:H\to G$ be a homomorphism, where $|G|=1$. Then $f$ must take the value of the one element of $G$ everywhere and is thus uniquely determined. If furthermore $g:G\to H$ is a homomorphism, by the homomorphism property we must have $g(\iota )=1_{H}$ (otherwise obtain a contradiction by taking a power of $\iota$).
Assume now that $|{\tilde {G}}|>1$, and let $\tau$ be an element within ${\tilde {G}}$ that does not equal the identity. Let $n:={\text{ord}}\tau$. We define a homomorphism $f:Z_{n}\to {\tilde {G}}$ by $f(k):=\tau ^{k}$. In addition to that homomorphism, we also have the trivial homomorphism $Z_{n}\to {\tilde {G}}$. Hence, we don't have uniqueness.$\Box$
Using the characterisation given by theorem 1.6, we may generalise this concept into the language of category theory.
Definition 1.7:
Let ${\mathcal {C}}$ be a category. A zero object of ${\mathcal {C}}$ is an object $Z$ of ${\mathcal {C}}$ such that for all other objects $X,Y$ of ${\mathcal {C}}$ there exist unique morphisms $f:X\to Z$ and $g:Z\to Y$.
Within many usual categories, such as groups (as shown above), but also rings and modules, there exist zero objects. However, not so within the category of sets. Indeed, let $S$ be an arbitrary set. If $|S|\geq 2$, then from any nonempty set there exist at least 2 morphisms with codomain $S$, namely the two constant functions. If $|S|=1$, we may pick a set $T$ with $|t|>2$ and obtain two morphisms from $S$ mapping to $T$. If $S=\emptyset$, then there does not exist a function $T\to S$.
But, if we split the definition 1.6 in half, each half can be found within the category of sets.
Definition 1.8:
Let ${\mathcal {C}}$ be a category. An object $X$ of ${\mathcal {C}}$ is called
* terminal iff for every other object $Y$ of ${\mathcal {C}}$ there exists exactly one morphism $Y\to X$;
* initial iff for every other object $Y$ of ${\mathcal {C}}$ there exists exactly one morphism $X\to Y$.
In the category of sets, there exists one initial object and millions (actually infinitely many, to be precise) terminal objects. The initial object is the empty set; the argument above definition 1.7 shows that this is the only remaining option, and it is a valid one because any morphism from the empty set to any other set is the empty function. Furthermore, every set with exactly one element is a terminal object, since every morphism mapping to that set is the constant function with value the single element of that set. Hence, by generalizing the concept of a zero object in two different directions, we have obtained a fine description for the symmetry breaking at the level of sets.
Now returning to the category of groups, between any two groups there also exist a particularly trivial homomorphism, that is the zero homomorphism. We shall also elevate this concept to the level of categories. The following theorem is immediate:
Theorem 1.9:
Let $T$ be the trivial group, and let $H$ and $G$ be any two groups. If $f:H\to T$ and $g:T\to G$ are homomorphisms, then $g\circ f$ is the trivial homomorphism.
Now we may proceed to the categorical definition of a zero morphism. It is only defined for categories that have a zero object. (There exists a more general definition, but it shall be of no use to us during the course of this book.)
Definition 1.10:
Let ${\mathcal {C}}$ be a category with a zero object $Z$, and let $X,Y$ be objects of that category. Then the zero morphism from $X$ to $Y$ is defined as the composition of the two unique morphisms $X\to Z$ and $Z\to Y$.