Kahibaro
Discord Login Register

Congruences

In modular arithmetic, congruences are the main way to write equations “modulo” some integer. In this chapter we focus on how congruences work, how to manipulate them, and some basic results that are constantly used in number theory and its applications.

Basic definition and notation

For integers $a,b$ and a positive integer $n$, we write
$$
a \equiv b \pmod n
$$
and read it as “$a$ is congruent to $b$ modulo $n$”.

This means that $a$ and $b$ leave the same remainder when divided by $n$, or equivalently, that their difference is divisible by $n$:
$$
a \equiv b \pmod n \quad \Longleftrightarrow \quad n \mid (a-b).
$$

Examples:

A useful way to think: $a \equiv b \pmod n$ says that $a$ and $b$ are in the same “remainder class” modulo $n$.

Basic properties of congruence

Congruence modulo a fixed $n$ behaves very much like equality. In particular, it satisfies:

These follow immediately from the divisibility condition $n\mid(a-b)$.

Because of these, you can treat a congruence like a kind of “equality modulo $n$” and do many of the same algebraic steps, as long as you stay consistent with the same modulus $n$.

Working with congruences

Addition and subtraction

If $a \equiv b \pmod n$ and $c \equiv d \pmod n$, then:

Example:

In practice, this means you can reduce numbers modulo $n$ at any stage to keep them small, then add or subtract.

Multiplication

If $a \equiv b \pmod n$ and $c \equiv d \pmod n$, then:
$$
ac \equiv bd \pmod n.
$$

In particular, if $a \equiv b \pmod n$, then for any integer $k$,
$$
ka \equiv kb \pmod n.
$$

Example:

Again, this lets you replace large numbers with smaller congruent ones before multiplying, which is especially useful for big powers.

Powers (repeated multiplication)

If $a \equiv b \pmod n$, then for any positive integer $k$,
$$
a^k \equiv b^k \pmod n.
$$

This follows by repeated use of the multiplication rule.

Example:

This is extremely useful for simplifying large exponent computations modulo $n$.

Cancellation and its limitations

With ordinary equalities, if $ac=bc$ and $c\neq 0$, you can cancel $c$ to conclude $a=b$. In congruences, there is a similar idea, but it comes with an important condition.

Suppose
$$
ac \equiv bc \pmod n.
$$
This means $n \mid c(a-b)$.

Example where cancellation succeeds:

Example where cancellation fails:

The key lesson: you may only “cancel” a factor $c$ in a congruence modulo $n$ if $c$ and $n$ are coprime.

Solving linear congruences

A linear congruence is an expression of the form
$$
ax \equiv b \pmod n,
$$
where $a,b,n$ are known integers and $x$ is unknown (an integer to be found).

Existence of solutions

Let $d = \gcd(a,n)$. Then:

This is a central fact about linear congruences.

Intuitively, dividing everything by $d$ turns the congruence into one where the coefficient of $x$ is coprime with the new modulus.

Reducing to a simpler congruence

Suppose $d=\gcd(a,n)$ and $d\mid b$. Write
$$
a = d a', \quad b = d b', \quad n = d n'.
$$
Then
$$
ax \equiv b \pmod n
\quad\Longleftrightarrow\quad
d a' x \equiv d b' \pmod{d n'}.
$$

You can divide the whole congruence by $d$:
$$
a' x \equiv b' \pmod{n'}.
$$

Now $\gcd(a',n') = 1$, so $a'$ has a multiplicative inverse modulo $n'$.

Once you find one solution modulo $n'$, you can lift it to obtain $d$ distinct solutions modulo $n$.

Using multiplicative inverses

If $\gcd(a,n)=1$, then $a$ has a multiplicative inverse modulo $n$. Call it $a^{-1}$; by definition it satisfies
$$
a a^{-1} \equiv 1 \pmod n.
$$

Then the congruence
$$
ax \equiv b \pmod n
$$
can be solved by multiplying both sides by $a^{-1}$:
$$
x \equiv a^{-1} b \pmod n.
$$

The main work is to find $a^{-1} \pmod n$, for example via the extended Euclidean algorithm (the details of that algorithm belong elsewhere in the course).

Example:
Solve
$$
3x \equiv 4 \pmod 7.
$$
Here $\gcd(3,7)=1$, so $3$ has an inverse modulo $7$.

Find $3^{-1} \pmod 7$:

Multiply both sides of $3x \equiv 4 \pmod7$ by $5$:
$$
x \equiv 5\cdot 4 \equiv 20 \equiv 6 \pmod7.
$$

So all integer solutions are of the form $x = 6 + 7k$ for integers $k$.

Example with multiple solutions:
Solve
$$
4x \equiv 8 \pmod{12}.
$$
Compute $d=\gcd(4,12)=4$. Since $4\mid 8$, solutions exist.

Divide everything by $4$:
$$
x \equiv 2 \pmod 3.
$$

The solutions to $x \equiv 2 \pmod 3$ are $x=2+3k$.

To get solutions modulo $12$, list those in one full cycle of length $12$:

Check:

There are $d=4$ distinct solutions modulo $12$, as the general theory predicts.

Systems of congruences and the idea behind Chinese remainders

Sometimes you want an integer $x$ that satisfies several congruences at once, such as
$$
\begin{cases}
x \equiv 2 \pmod 3,\\
x \equiv 1 \pmod 4.
\end{cases}
$$

This is a system of congruences. When the moduli are coprime, such systems behave especially well: there is a unique solution modulo the product of the moduli. This is the content of the Chinese Remainder Theorem, which is treated in more depth elsewhere.

For now, the important congruence-related idea is that:

You can often solve small systems by trial or simple reasoning, using your knowledge of congruences.

Using congruences in practice

Congruences are widely used for:

In many later topics, especially in number theory and cryptography, expressions of the form
$$
a \equiv b \pmod n
$$
are the basic “equations” you solve and manipulate. The rules and examples in this chapter form the core toolkit for that work.

Views: 10

Comments

Please login to add a comment.

Don't have an account? Register now!