# Formal proof that a is congruent to (a mod m) (mod m) [duplicate]

Intuitively it is quite easy to see why $$a \equiv (a \bmod m) \pmod m.$$

When you divide a by m you get a remainder in the range $$0, \dots, m-1.$$ When you divide the remainder by m again, you get the same number again as the remainder, except that this time the quotient is 0.

I get that.

The question is how to prove it formally.

• $+$ve? It obviously depends on how you define $(a\bmod m)$ and $x\equiv y\pmod m.$ But you should be able to prove this straight from the definitions, no matter which definitions you use. Oct 23 at 22:05
• A good first step is to recall the formal definition of $a \bmod m$ -- more specifically, to recall the formal definition previously given by whoever stated the theorem, because that will give specific steps to take. In fact there are five different definitions on the Wikipedia page alone! Although I would say that the statement you're trying to prove is practically part of the definition of a binary mod operator, because I would not call any operator that violated this condition a mod operator. Oct 23 at 22:07
• Conceptually this is an immediate consequence of the boxed equivalence in the first linked dupe.,since $(a\bmod m) \bmod m = a\bmod m.$ by here. See also Arturo's answer in the 2nd linked dupe, and see the 3rd dupe for general discussion. Oct 24 at 0:42

At heart, you need this version of the division algorithm to even define $$(a\bmod m).$$

Let $$a,m\in\mathbb Z, m\neq 0.$$ Then there is a unique pair $$q,r\in \mathbb Z$$ such that $$a=mq+r$$ and $$0\leq r<|m|.$$

Often, division algorithm does not include uniqueness. Depending on whether you’ve already proven division algorithm this way, you might have to prove a corollary to get uniqueness.

From that theorem, you define $$(a\bmod m):=r,$$ since $$r$$ is unique. Without uniqueness, you can’t even define $$a\bmod m.$$

But then $$a-(a\bmod m)=a-r=mq$$ is divisible by $$m,$$ so $$a\equiv (a\bmod m)\pmod m,$$ by definition.

That assumes you’ve defined congruence the easiest and most usual way:

$$x\equiv y\pmod m$$ iff $$x-y$$ is divisible by $$m.$$

Your approach would seem to indicate a slightly harder definition:

$$x\equiv y\pmod m$$ iff $$(x\bmod m)=(y\bmod m).$$

Then you would want to show: $$((a\bmod m)\bmod m)=(a\bmod m).\tag1$$

That follows from:

Lemma: If $$0\leq c<|m|,$$ then $$(c\bmod m)=c.$$
Proof: Eince $$c=m\cdot 0+c$$ satisfies the division algorithm condition, with $$q=0, r=c,$$ you are done.

Then, by definition of $$a\bmod m,$$ you’d have $$0\leq (a\bmod m)<|m|,$$ and hence you can conclude $$(1)$$ from the Lemma.

As you can see, all the work is really in the definitions, and which definitions you choose.

In first order logic formalism, we can’t even define new terminology. We have to replace all terms like “$$a\bmod m$$“ and “$$x\equiv y\pmod m$$” and “$$|m|$$” and “$$k$$ is divisible by $$m$$“ by their definitions.

In Peano Axioms for the natural numbers (non-negative integers,) we can’t even talk about “$$x-y$$” in general.

Nobody wants to do that.

Let $$q$$ and $$r$$ be integers such that $$a=qm+r$$ (with $$0 \leq r < m$$). It's easy to see that $$a \mod m$$ is precisely $$r$$.

Now we can write $$a - (a \mod m)$$ as just $$qm$$ which is clearly a multiple of $$m$$. Therefore $$a$$ is congruent to $$(a \mod m)$$ $$(\mod m)$$