Introduction to UFDs

(This is Glen.)

I was sorting through the LaTeX files on my computer and unearthed an old set of solutions to a mysterious problem set, dated 2020. After a bit of digging in some old Discord servers, I found out that these were solutions to one of Zhao Yu's sets for some RI training, which I had presumably crashed because it was online (thanks to Covid) and I was too free or something. Anyway, this file contained a lengthy introduction to UFDs, which I had recently learnt about in uni and had used to overkill a couple of problems in the set. This is, I think, quite suitable for a blog post, so here we are.

The fundamental theorem of arithmetic

As a warmup, let's think about something we learn about in primary school (well, at least I remember learning about this in primary school but I am old so this may no longer be the case): the unique prime factorisation of integers.

(Fundamental theorem of arithmetic) Each integer n>1n>1 can be written uniquely as n=p1pkn=p_1\cdots p_k, where the pip_i are primes, up to reordering of the prime factors.

To be specific, this says two things:

  1. Each n>1n>1 can be written as n=p1pkn=p_1\cdots p_k, where the pip_i are primes.
  2. If p1pk=q1qp_1\cdots p_k = q_1\cdots q_\ell are products of primes, then k=k=\ell and the pip_i are a reordering of the qjq_j.

To clarify, by "prime number" I mean a positive integer that's only divisible by itself and 11.

Let's try to prove this - it's trickier than you might think! The first point isn't that bad: suppose nn is not prime, then it has a factor that isn't 11 or nn. Pick the smallest such factor, then this has to be a prime pp. Divide nn by pp, and repeat inductively. The process eventually stops because the value of nn decreases each time we divide.

The second point is the hard one. What we want to show is probably something along the lines of: p1p_1 divides the RHS, so one of the qjq_j is equal to p1p_1, then we can cancel both terms and induct, which means we want some result of the form "if a prime pp divides the product a1aka_1\cdots a_k, then pp divides one of the aia_i". But why is this true? Well, sure, you might think it's intuitively true, but that's probably because the uniqueness of prime factorisation is so deeply ingrained that it's just common sense. However, we can't quote this, since then our proof would be circular. So what now?

It turns out that the answer is some other fundamental thing which we first learn about in Senior Team (again, I'm old so the syllabus may have changed, etc. etc.): the Euclidean algorithm.

The Euclidean algorithm

Let's recall what this is. Suppose we have two positive integers a,ba,b, and we want to find gcd(a,b)\gcd(a,b) (defined to be the largest positive integer which divides both of them). One way to do this (as I learnt in primary school) is to prime factorise both numbers, and then pick the minimum exponent of each prime. But we're trying to prove the uniqueness of prime factorisation, so we can't do this. Instead, there is an algorithm which everyone who does olympiads has heard about thanks to IMO 1959/1: the Euclidean algorithm. Here's how it goes: at each step, replace the larger of the numbers (WLOG bb) with its remainder when divded by aa; terminate when said remainder is 00.

Here's an example: let's say a=267,b=31a=267,b=31. Then we go (267,31)(19,31)(19,12)(7,12)(7,5)(2,5)(2,1)(0,1)(267,31) \rightarrow (19,31) \rightarrow (19,12) \rightarrow (7,12) \rightarrow (7,5) \rightarrow (2,5) \rightarrow (2,1) \rightarrow (0,1), so the algorithm outputs 11.

Why does this work? Well, kak|a and kbk|b iff kak|a and k(ba)k|(b-a), so gcd(a,b)=gcd(a,ba)\gcd(a,b) = \gcd(a,b-a). Combine this with the fact that gcd(m,0)=m\gcd(m,0)=m and induct.

Great, but why is this useful? It turns out that this gives a (constructive!) proof of:

(Bézout's theorem) Let a,ba,b be integers. Then there exist integers m,nm,n such that am+bn=gcd(a,b)am+bn = \gcd(a,b).

The idea of the proof is to "reverse" the Euclidean algorithm. I don't want to write down a bunch of algebra, so I'll illustrate it with the example from above. Rewrite the steps of our algorithm as: 2678×31=193119=121912=7127=575=252×2=1\begin{align*}267 - 8\times 31 &= 19 \\ 31 - 19 &= 12 \\ 19 - 12 &= 7 \\ 12 - 7 &=5 \\ 7-5 &= 2 \\ 5 - 2\times 2 &= 1\end{align*} Now, substitute everything in turn: 19=2678×3112=31(2678×31)=9×312677=(2678×31)(9×31267)=2×26717×315=(9×31267)(2×26717×31)=26×313×267 2=(2×26717×31)(26×313×267)=5×26743×311=26×313×2672(5×26743×31)=112×3113×267\begin{align*} 19 &= 267 - 8\times 31 \\ 12 &= 31 - (267 - 8\times 31) = 9\times 31 - 267 \\ 7 &= (267-8\times 31) - (9\times 31 - 267) = 2\times 267 - 17\times 31 \\ 5 &= (9\times 31 - 267) - (2\times 267 - 17\times 31) = 26\times 31 - 3\times 267  \\ 2 &= (2\times 267 - 17\times31) - (26\times 31 - 3\times 267) = 5\times 267 - 43\times 31 \\ 1 &= 26\times 31 - 3\times 267 - 2(5\times 267-43\times31) = 112\times 31 - 13\times 267\end{align*}

With this in hand, we can prove the uniqueness half of the fundamental theorem of arithmetic.

Uniqueness of prime factorisation

We'll show that if pabp|ab for pp prime, then pap|a or pbp|b. Indeed, suppose pp doesn't divide aa, then gcd(a,p)=1\gcd(a,p)=1 (since it can't be pp), and so by Bézout, there exist integers m,nm,n for which pm+an=1pm + an = 1. Multiply bb to both sides, then we have pmb+abn=bpmb + abn = b. But the LHS is divisible by pp, so pbp|b.

Now, induction on kk tells us that if pa1akp|a_1\cdots a_k, then paip|a_i for some ii, which is exactly the fact that we needed to complete the proof.

I'm not too sure how new this is to you (I, for one, went through most of my life without ever thinking about why the fundamental theorem of arithmetic is true), but in any case, you should be warmed up for what comes next.

Unique factorisation domains

We want to generalise the idea of unique factorisation of integers. These end up being mathematical objects called rings. Roughly speaking, a ring is a set of numbers with the operations +,,×+,-,\times in the usual sense, but not ÷\div. Specifically it's a set RR with operations ++ and ×\times such that:

  • +,×+,\times are associative
  • ++ is distributive over ×\times
  • ++ is commutative
  • there exist elements 0,1R0,1\in R such that 0+a=1×a=a×1=a0+a = 1\times a = a\times 1 = a for all aRa\in R
  • for every aRa\in R, there exists an element aR-a\in R such that a+(a)=0a + (-a) = 0.

Additionally, we also tend to assume that ×\times is commutative.

Here are some examples of rings: Z\mathbb{Z},Q\mathbb{Q}, R\mathbb{R}, Z[X]\mathbb{Z}[X] (polynomials in Z\mathbb{Z}), R[X,Y,Z]\mathbb{R}[X,Y,Z], Z/nZ\mathbb{Z}/n\mathbb{Z} (integers mod nn),  Q[i]={a+bia,bQ}\mathbb{Q}[i] = \{a+bi|a,b \in \mathbb{Q}\}, continuous functions f:RRf:\mathbb{R}\rightarrow\mathbb{R} (with pointwise addition and multiplication). n×nn\times n matrices also work if we allow ×\times to not be commutative. N\mathbb{N} is not a ring because it fails the last property.

A ring is an integral domain if ab=0a=0ab = 0 \Rightarrow a=0 or b=0b=0. A non-example would be Z/4Z\mathbb{Z}/4\mathbb{Z}, since 2×2=02\times2 = 0 in this ring. All our rings with be integral domains from now on.

Now, for an integral domain RR, we want to generalise our definition of unique prime factorisation. To do this, we have to fix our definition of "prime". I guess we're all used to the definition that says that a prime number is an integer that's only divisible by 11 and itself, but that's not entirely accurate: if one is being extremely pedantic, a prime number pp has four factors 1,1,p,p1,-1,p,-p. Of course, this is kind of silly because pp and p-p are "the same"; they differ by multiplication by 1-1, which doesn't really matter, because it has a multiplicative inverse (itself). So the multiples of pp are exactly the multiples of p-p, and hence they are really the same thing for divisibility purposes.

Elements which have a multiplicative inverse (i.e. aa for which ab=1ab=1 for some bb) are called units. For example, in Z\mathbb{Z}, the units are ±1\pm1 while in R\mathbb{R}, the units are everything except for 00. Our definition of prime generalises as follows: pRp\in R is called irreducible if p0p\ne 0, pp is not a unit, and apa|p (i.e. p=abp=ab for some bb) implies aa is a unit or pp times a unit.

Confusingly, ring theorists also have a definition for "prime": pRp\in R is called prime if p0p\ne 0, pp is not a unit, and pabpap|ab \Rightarrow p|a or pbp|b.

(A note on the conditions p0p\ne0 and pp is not a unit: this should intuitively make sense since we don't call 00 and 11 prime numbers.)

In Z\mathbb{Z}, "prime" and "irreducible" are just our usual notions of prime, but in general, these do not have to coincide! We'll see some examples later. Even so, they are still related: primes are irreducible. Indeed, if pp is prime and p=abp=ab, then pap|a or pbp|b. In the former case, a=pqa = pq for some qq, so p=pqbp = pqb, i.e. p(1qb)=0p(1-qb) = 0. Since p0p\ne 0, then qb=1qb=1, so bb and qq are units, and a=pqa=pq is pp times a unit. In the latter case, a similar argument shows that aa is a unit.

We are finally ready to define a UFD. A unique factorisation domain is an integral domain RR such that for each nonzero nRn\in R,

  1. nn can be written as n=up1pkn = up_1\cdots p_k, where uu is a unit and the pip_i are irreducibles.
  2. If p1pk=q1qp_1\cdots p_k = q_1\cdots q_\ell are products of irreducibles, then k=k=\ell and we may reorder the qjq_j such that for each ii, pip_i and qiq_i differ by multiplication by a unit.

(In the case where nn is a unit, we have k=0k=0.)

The annoying wording of the second point is to allow things like 2×3×5=(2)×3×(5)2\times3\times5 = (-2)\times3\times(-5). When working over integers, we can always choose our irreducibles to be positive, but in general, rings don't have any notion of positive or negative, so we have to bake the ambiguity of multiplying by units into the definition.

The fundamental theorem of arithmetic says that Z\mathbb{Z} is a UFD. Additionally, somewhat tautologically, all fields (e.g. Q,R,C\mathbb{Q},\mathbb{R},\mathbb{C}) are UFDs. But what else?

Before we proceed, first let us note that we may replace the second condition with: "all irreducibles are primes". Indeed, this implies the original second condition using our inductive argument from the Z\mathbb{Z} case, and conversely, in a UFD, if pabp|ab for an irreducible pp, then we can prime factorise both aa and bb, and pp (times a unit) must appear in one of their prime factorisations. This is, in general, the more useful version of the definition of a UFD.

Euclidean domains

When we proved that Z\mathbb{Z} is a UFD, we used the Euclidean algorithm. What exactly made it work? We needed to be able to take the remainder of the "bigger" number when divided by the "smaller" number, and this remainder had to be "smaller" than both the original numbers, so the algorithm could eventually terminate. But in general, we don't really have a notion of bigger or smaller (how do you compare two continuous functions from R\mathbb{R} to R\mathbb{R}?) 

In fact, this is also problematic because now our usual definition of a gcd doesn't work. This can be fixed in the following way: dd is a gcd of a,ba,b if da,dbd|a,d|b and for all dd' such that da,dbd'|a, d'|b, we have ddd'|d. So instead of being "greatest" by size, dd is now "greatest" in the sense that it contains all other common divisors. Note that gcds are now only well-defined up to multiplication by a unit (in Z\mathbb{Z}, dd and d-d can both be gcds but we just pick the positive one by convention): if ddd|d' and ddd'|d, i.e. d=dad=d'a and d=dbd'=db, then d(ab1)=0d(ab-1)=0, so a,ba,b are units.

Anyway, a gcd is a thing that can be defined in general rings. Now, if we can define a notion of bigger/smaller that makes the Euclidean algorithm work, then we have a Euclidean domain.

More specifically, a Euclidean domain is an integral domain RR with a "size" function f:RZ0+f: R \rightarrow \mathbb{Z}_0^{+} such that

  • f(r)=0f(r) = 0 iff r=0r=0
  • for each nonzero a,bRa,b\in R, we may write a=bq+ra=bq+r where f(r)<f(b)f(r) < f(b) (so we have a notion of "remainder")

For R=ZR=\mathbb{Z}, f(r)=rf(r) = |r| works. A more non-trivial example is R[X]\mathbb{R}[X], for which the degree is a valid ff (because of polynomial long division).

Euclidean domains are UFDs

Now would be the time to scroll up to the section on the Euclidean algorithm and check that in a Euclidean domain, the Euclidean algorithm terminates, and that its output is a gcd. Moreover, the same arguments give us Bézout's theorem, from which we may deduce (as in the Z\mathbb{Z} case) that irreducibles are prime.

On the other hand, all nonzero nRn\in R have a factorisation into irreducibles: If nn is irreducible, we're done. Otherwise, we may write n=abn=ab, where neither aa nor bb is a unit or nn times a unit. We want f(a),f(b)<f(n)f(a),f(b)<f(n), so we may induct. Suppose that f(a)f(n)f(a)\ge f(n). Then, applying the Euclidean algorithm on a,na,n, the first step is anq=ra - nq = r. If r=0r=0, then ana|n and nan|a, so aa is nn times a unit, contradiction. Hence, the Euclidean algorithm terminates after the first step, and so gives us some gcd aa' of a,na,n for which f(a)<f(n)f(a') < f(n). But now a,aa,a' are both gcds for a,na,n, so aa is aa' times a unit. We may thus rewrite n=uabn=ua'b', where uu is a unit and f(a),f(b)<f(n)f(a'),f(b') < f(n), and then we're done by induction.

The second paragraph here is somewhat annoying and technical, but really, the main property that we'll be using is the result of the first paragraph.

Actual olympiad usage

You might be wondering why I've put you through that long ramble on abstract algebra. If so, here comes the pay-off.

Primes that are 1 mod 4

The following lemma is a semi-famous fact which has various proofs, none of which I could ever reproduce except for the UFD proof.

Let p1(mod4)p\equiv 1\pmod 4 be a prime number. Then p=a2+b2p=a^2+b^2 for some integers a,ba,b.

As far as I know, all proofs use the fact that 1-1 is a quadratic residue mod pp, i.e. there's an integer nn such that pn2+1p|n^2+1. You can prove this using the existence of a primitive root, but actually, there's an even more low-powered way of showing this using Wilson's theorem: (p12)!2(1×2××p12)×((1)×(2)××(p12)) (p1)!1(modp)\left(\frac{p-1}2\right)!^2 \equiv \left(1\times 2 \times\cdots \times \frac{p-1}2\right) \times \left((-1)\times (-2) \times\cdots \times \left(-\frac{p-1}2\right)\right) \equiv (p-1)! \equiv -1\pmod{p}

So we have pn2+1p|n^2+1. Now what? We want to rewrite this as pabp|ab, and the only natural way of doing this is n2+1=(n+i)(ni)n^2+1 = (n+i)(n-i), which looks...somewhat illegal. But this is legal if we work in a ring that contains ii, i.e. Z[i]={a+bia,bZ}\mathbb{Z}[i] = \{a+bi|a,b\in\mathbb{Z}\}.

Let's prove that Z[i]\mathbb{Z}[i] is a Euclidean domain, so it will be a UFD. We need to write down a function ff, and there's a fairly natural one that works: let f(a+bi)=a2+b2f(a+bi) = a^2+b^2. Now, given m,nZ[i]m,n \in \mathbb{Z}[i], the multiples of mm form a square lattice in C\mathbb{C} whose squares have side length f(m)\sqrt{f(m)}.

Then, our division/remainder condition boils down to the geometric fact that a point inside a square is at most 22<1\frac{\sqrt{2}}2 < 1 times the side of the square away from one of the vertices.

Great, so how do we use this fact? Let's look again at pn2+1=(n+i)(ni)p|n^2+1 = (n+i)(n-i). Suppose pp is irreducible in Z[i]\mathbb{Z}[i], then it's prime, so p(n+i)p|(n+i) or p(ni)p|(n-i). This is obviously impossible since n±ip\frac{n\pm i}p isn't of the form a+bia+bi, a,bZa,b\in \mathbb{Z}. Alternatively, we could use the fact that ff is multiplicative: f(mn)=f(m)f(n)f(mn) = f(m)f(n) (because for complex numbers, ab=ab|ab| = |a||b|), so if p(n±i)p|(n\pm i), then f(p)f(n±i)f(p)|f(n\pm i), i.e. p2pp^2|p, contradiction.

In other words, pp is not irreducible in Z[i]\mathbb{Z}[i](!), so there exists some (non-unit, non-pp-times-unit) a+bia+bi such that (a+bi)p(a+bi)|p. Then f(a+bi)f(a+bi) is a factor of f(p)=p2f(p) = p^2 that isn't 11 or p2p^2, so f(a+bi)=pf(a+bi)=p, i.e. a2+b2=pa^2+b^2=p.

A Diophantine equation

Here's a problem (slightly adapted) from my homework from when I was learning about UFDs:

Solve x2+2=y3x^2+2 = y^3 in integers.

It's tempting to factorise the LHS, isn't it? We have y3=(x+2)(x2)y^3 = (x+\sqrt{-2})(x-\sqrt{-2}). For this to go anywhere, we need Z[2]={a+b2a,bZ}\mathbb{Z}[\sqrt{-2}] = \{a + b\sqrt{-2}|a,b \in \mathbb{Z}\} to be a UFD. Indeed, it's a Euclidean domain by setting f(a+b2)=a2+2b2f(a+ b\sqrt{-2}) = a^2+2b^2; the same proof as in Z[i]\mathbb{Z}[i] holds by replacing the squares with rectangles of side ratio 1:21:\sqrt{2}. Note that this ff is again multiplicative.

Now, it would be nice if the x±2x\pm\sqrt{-2} are coprime, so each term would be a square in Z[2]\mathbb{Z}[\sqrt{-2}]. Well, their difference is 22=232\sqrt{-2} = -\sqrt{-2}^3, which is a factorisation into irreducibles (since f(2)=2f(\sqrt{-2}) = 2 is a prime number). On the other hand, if 2x\sqrt{-2}|x, then xx is even, so y3=x2+2y^3 = x^2+2 is even, so a multiple of 88, but then the RHS is 2(mod4)2 \pmod4, contradiction. Hence, the x±2x\pm\sqrt{-2} are coprime, so we have (by unique factorisation) x+2=(a+b2)3x + \sqrt{-2} = (a + b\sqrt{-2})^3 for some a,bZa,b \in \mathbb{Z}.

Expand the RHS and compare real and imaginary parts, so we have x=a36ab2x = a^3 - 6ab^2 and 1=3a2b2b3=b(3a22b2)1 = 3a^2b - 2b^3 = b(3a^2 - 2b^2). The second equation immediately tells us b=±1b = \pm 1. The b=1b=1 case gives a=±1a=\pm 1, while the b=1b=-1 case gives us some a∉Za \not\in\mathbb{Z}. Hence, we have x=a36ab2=±5x = a^3 - 6ab^2 = \pm 5. Checking, this gives us the solutions (x,y)=(±5,3)(x,y) = (\pm5, 3), which are the only solutions.

Exercise: primes that are 1 mod 3

Here's a problem from Zhao Yu's problem set:

Show that every prime of the form 3k+13k+1 can be written as x2+3y2x^2+3y^2 for integers x,yx,y.

I'll sketch an outline; do try to fill in the details yourself!

  • By quadratic reciprocity, pn2+3p|n^2+3 for some nn. (Edit: Jit Wu dug through some old textbook and found this trick due to Euler: n=2gk+1n = 2g^k + 1, where gg is a primitive root, works. Cool.)
  • The geometric proof doesn't work to show that Z[3]\mathbb{Z}[\sqrt{-3}] is a Euclidean domain (why?). In fact, Z[3]\mathbb{Z}[\sqrt{-3}] is not a UFD: 2×2=(1+3)(13)2\times 2 = (1+\sqrt{-3})(1-\sqrt{-3}). (In particular, 22 is an irreducible which is not a prime - can you see why? Hint: the fast way to see this is to use the fact that the ff we have been using is multiplicative.)
  • However, if we let ω=1+32\omega = \frac{1+\sqrt{-3}}2, then Z[ω]\mathbb{Z}[\omega] is a Euclidean domain (how does the geometric proof change? What is ff?) and thus a UFD.
  • There exist integers a,ba,b such that f(a+bω)=pf(a+b\omega) = p. If bb is even, we're done (why?).
  • Multiply a+bωa+b\omega by units to get to something of the right form.
A brief remark on the second bullet point: Z[3]\mathbb{Z}[\sqrt{-3}] isn't a UFD, but for people who do number theory, it somehow isn't the right object to consider (roughly speaking, it's because the set of numbers of the form a+b3a+b\sqrt{-3} which are roots of a monic integer polynomial isn't Z[3]\mathbb{Z}[\sqrt{-3}], but Z[ω]\mathbb{Z}[\omega]). As such, the usual non-example of a non-UFD is Z[5]\mathbb{Z}[\sqrt{-5}], in which 2×3=(1+5)(15)2\times 3 = (1+\sqrt{-5})(1-\sqrt{-5}). By considering the squares of their magnitudes (as we have been doing in our other rings), we may show that all four terms there are irreducible, but not prime.

Geometry bashing

A key fact about UFDs is the following corollary of Gauss' lemma:

If RR is a UFD, then R[X]R[X] is a UFD.

Thus, by induction, Z[X1,,Xk]\mathbb{Z}[X_1,\ldots,X_k] is a UFD for all kk. This is important for geometry bashing, because (unless something has gone very wrong) all expressions are fractions of integer polynomials. You'll probably never have to use this fact in a proof, but knowing that integer polynomials (in however many variables) form a UFD is very useful for algebraic intuition and knowing when to avoid expanding things unnecessarily. I'll probably write about this more when (if) I write an introductory bashing post. 

Anyway, that's it for now. I hope you've enjoyed this little teaser of abstract algebra.

Comments

Popular posts from this blog

SMO Open 2024 ??% Speedrun

Musings about the IMO