4

modular arithmetic

How Can I prove (a+b) mod m = (a mod m) + (b mod m)) mod m ?

  • 1
    Before it can be proven, you have to have a definition for $\rm mod$. What is your definition of it? – DanielV Mar 05 '15 at 13:39
  • 1
    This question is a bit confusing. You seem to have too many (mod m)s. Are you trying to prove equality in Z of least positive representatives or equality in Z/mZ? – SE318 Mar 05 '15 at 13:39

3 Answers3

2

Let $a\mod m= a_1$ and $b\mod m = b_1$.

Then

$$\begin{cases}m\mid a-a_1\\m\mid b-b_1\end{cases}\implies m\mid a+b-(a_1+b_1)$$

$$\iff a+b\equiv a_1+b_1\pmod{m}\iff (a+b)\mod m=(a_1+b_1)\mod m\\\iff (a+b)\mod m =((a\mod m)+(b\mod m))\mod m\ \ \ \square$$

user26486
  • 11,331
  • I am not clear about the notation m|a . please explain. – Shakhawat Hossain Mar 05 '15 at 13:32
  • You need to be careful here. If you say $a mod m= a_1$ then a is an integer and $a_1$ is a set of integers. This causes some problems. – SE318 Mar 05 '15 at 13:35
  • 1
    $m\mid a$ is the notation for "$m$ divides $a$", or "$a$ is divisible by $m$". Formally, $m\mid a\iff \exists k\in\mathbb Z(a=mk)$. – user26486 Mar 05 '15 at 13:35
  • @SE318 No. See this Wikipedia article. $a\mod m$ is defined to be $r$ such that $a=lm+r$ for some integer $l$, where $r\in\mathbb Z, 0\le r<m$. – user26486 Mar 05 '15 at 13:36
  • @user314, I see what you're saying. I've never seen it defined in this way in any of my math classes though as this lead to ambiguity as to if you're just finding the remainder, or passing into the quotient space. It's probably just a difference in definitions though, depending on which textbook you use, they can define these things with slight(but important!) differences. – SE318 Mar 05 '15 at 13:50
  • @SE318 You might have in mind the modular equivalence relation and equivalence of integers there. $a\equiv b\pmod {m}$ just means that $m\mid a-b$, and $b$ can be any integer of the form $b=wm+a, w\in\mathbb Z$. – user26486 Mar 05 '15 at 13:54
  • Yeah, I just looked at my undergraduate AA book (AA an introduction 2nd edition by Hungerford). In there, they define modular arithmetic solely in terms of arithmetic in Z/mZ. I can definitely see how using it to just define the remainder after the division algorithm could be used as well(especially in a more CS/application based math course rather than a purely abstract math course) – SE318 Mar 05 '15 at 14:06
  • @user26486. Thank you very much. Can you show how to do it for $ ab \mod m = (a \mod m)(b \mod m) \mod m$ – Avv Mar 15 '21 at 02:52
  • How we can we conclude that $$(a+b)\mod m=(a\mod m+b)\mod m?$$I try use your idea but I get stuck. – tstt Jan 12 '23 at 05:57
1

Using $\,\ c\equiv d\pmod m\color{#c00}\iff \bar c = \bar d,\ $ where $\,\ \bar n := (n\bmod m)\ $

${\rm mod}\ m\!:\,\ a\color{#c00}\equiv \bar a$
$\qquad\qquad\, b\color{#c00}\equiv \bar b$
$\ \, \Rightarrow\,\ a+b\equiv \bar a + \bar b\,\ $ by the $ $ Congruence Sum Rule

$\color{#c00}\Rightarrow\, (a+b)\ {\rm mod}\ m\, \equiv\, (\bar a + \bar b)\ {\rm mod}\ m,\,\ $ which is the titled claim.

Remark $ $ Generally, as above, to prove an identity about mod as an operator it is usually easiest to first convert it into the more flexible congruence form, prove it using congruences, then convert back to operator form.

Bill Dubuque
  • 272,048
0

If $\pmod m$ just means that you subtract or add multiples of $m$ until you end up in the range $0,1,2,...,m-1$ then the RHS is easily compared to the LHS by collecting multiples of $m$.

String
  • 18,395