Why is the associative property valid for modular arithmetic?

Hint:

The author proves

enter image description here

The $\mathbf{mod} \, m$ function has the property that

$\tag 1 [a \, \mathbf{mod} \, m] \, \mathbf{mod} \, m = a \, \mathbf{mod} \, m$

so, using corollary 2, this is also true,

$\tag 2 (a + b)\, \mathbf{mod} \, m = [a + b \, \mathbf{mod} \, m] \, \mathbf{mod} \, m$


Since there is an accepted completed answer, "here is how it is done strictly":

$\quad (a +_m b)+_m c =[(a +_m b) + c] \, \mathbf{mod} \, m = \big[(a + b) \, \mathbf{mod} \, m + c\big] \, \mathbf{mod} \, m =$
$\quad \quad \big[(a + b) + c\big] \, \mathbf{mod} \, m = \big[a + (b+c)\big] \, \mathbf{mod} \, m = \big[a + (b+c) \, \mathbf{mod} \, m \big] \, \mathbf{mod} \, m = $
$\quad \quad \big[a + (b+_mc)\big] \, \mathbf{mod} \, m = a +_m (b+_m c)$


The key is to show that $$a+_m(b+_mc)=[a+(b+c)]\mbox{ mod $m$}$$ (and similarly for $(a+_mb)+_mc$). Using the definition of modular arithmetic you've quoted this goes through the fact that $$a+(b+_mc)\equiv a+(b+c)\quad\mbox{ mod $m$}.$$ This is a little cringe-inducing since it mixes integers and integers-mod-$m$; this is in keeping with the definition you've written, but doesn't make sense if we define $\mathbb{Z}_m$ via equivalence classes instead (this is the standard approach, which is more complicated at the outset but ultimately much nicer), and then a slightly different reasoning is needed.

Note that this is all a bit slippery until we've shown that "$+_m$" is in fact well-defined - if you haven't yet, you should do that first.


At that point, associativity of $+_m$ follows immediately from associativity for $+$: we have $$a+(b+c)=(a+b)+c\implies [a+(b+c)]\mbox{ mod $m$}=[(a+b)+c]\mbox{ mod $m$}.$$ This is just a slightly messy example of the more general fact that $$x=y\implies x\mbox{ mod $m$}=y\mbox{ mod $m$},$$ that is, that "mod" is well-defined.