0

I've gone through the similar post Modulo of a negative number . But that post is not about proof and I'm asking for the proof in general.

This question is another follow up question of my previous question. The question is how can we prove that $(a-b) \mod N = a \mod N + ((-b) \mod N)$.

user103816
  • 3,831
  • What is the exact definition of $ x \bmod N$ that you are working with? – davidlowryduda Jul 29 '15 at 15:23
  • What do you mean my $a \bmod N$? Is your $=$ supposed to mean the two expressions are equal as integers? [In arithmetic modulo $N$ we would normally treat two integers which differ by a multiple of $N$ as being 'the same' or equivalent] – Mark Bennet Jul 29 '15 at 15:24
  • @mixedmath By $x \mod N$ I mean the remainder leftover when $x$ is divided by $N$. $x$ can be negative and the remainder must be less than $N$ and must be positive. – user103816 Jul 29 '15 at 15:26
  • @MarkBennet My = means they are numerically equal. Please do not confuse it with $\equiv$. – user103816 Jul 29 '15 at 15:27
  • If you use mod to mean remainder, as is common in Computer Science but not in Number Theory, then the assertion is false. Let $a=2$ and $b=1$, with say $N=7$. Then the left side is $1$ and the right side is $8$. – André Nicolas Jul 29 '15 at 15:31
  • 1
    Then your formula should be: $(a-b)\bmod N=(a\bmod N+( -b)\bmod N)\bmod N$. – Bernard Jul 29 '15 at 15:31
  • 1
    @user103816 Then, as others have said, the assertion cannot be proved. Whatever definition you choose - e.g. least non-negative residue, or residue of least absolute value (positive for tie break) - you will be able to find values for which the two expressions are not equal. – Mark Bennet Jul 29 '15 at 15:36
  • @MarkBennet Then how is $6\mod7=(-1)\mod7$? And is the formula posed here incorrect? – user103816 Jul 29 '15 at 15:43
  • @user103816 You have that $6-(-1)=7$ - any two numbers whose difference is divisible by $7$ are equivalent modulo $7$ - that is one way of defining the concept. – Mark Bennet Jul 29 '15 at 16:06
  • @MarkBennet How can we prove that any two numbers(positive or negative) which are divisible by $x$ are equivalent modulo $x$? – user103816 Jul 29 '15 at 16:09
  • @MarkBennet Isn't $(( -b)\bmod N)\bmod N=(-b)\bmod N$? – user103816 Jul 29 '15 at 16:17

2 Answers2

2

The comments are getting complicated.

The main point of working modulo $N$ is to make multiples of $N$ irrelevant, so we define $a\equiv b \bmod N$ if and only if $N\mid a-b$ or equivalently if there is an integer $r$ with $a=b+rN$.

The relation $\equiv$ defined in this way is easily seen to be an equivalence relation which divides the integers $\mathbb Z$ into $N$ equivalence classes.

It is easily seen that $(a+kN)+(b+rN)=a+b+(k+r)N$

and $(a+kN)(b+rN)=ab+(ar+bk+krN)N$

So addition and multiplication respect equivalence.

One way of doing arithmetic modulo $N$ is to choose a representative element of each equivalence class. Often this is the remainder on division by $N$, giving representatives $0, 1, 2 \dots N-1$ (I'll call this the standard set). Sometimes it is more convenient to choose the residues of least absolute value (with $N/2$ taken for the relevant class if $N$ is even).

As regards negative numbers we have $-b\equiv N-b\equiv 2N-b \dots$ and this will eventually give a positive residue.

Though it makes sense to choose a set of representatives of the classes - for example, the standard set - and do our arithmetic using these, it is easy to see that these cannot be closed under addition or multiplication* (take the residue of greatest absolute value and add it to itself, or square it). The result may have to be adjusted by a multiple of $N$ to give the required residue. The same is true of subtraction.

You can either try to work over the integers and have to adjust your results by multiples of $N$ to get equality, or you can work with equivalences throughout.

If in doubt go back to the definition and work over $\mathbb Z$ using arbitrary multiples of $N$ - the language of equivalence does the same job whilst simplifying the expressions and the arithmetic.


*For multiplication there is an exception: the residues $\{0,1\}$ are closed under multiplication modulo $2$

Mark Bennet
  • 100,194
1

We would like to prove that:

$(a-b) \text{ mod } N = (a \text{ mod } N + (-b) \text{ mod } N) \text{ mod }N$

and

$(a-b) \text{ mod } N = (a \text{ mod } N -b \text{ mod } N) \text{ mod }N$

Let us first start proving that $c=(a+b) \text{ mod } N = (a \text{ mod } N + b \text{ mod } N) \text{ mod }N$

This means, in other words, that:

(1) $ a+b = c+Nf : 0<c<N\rightarrow c=(a+b) \text{ mod } N $

(2) $a = r+Nk : 0<r<N\rightarrow r=a \text{ mod } N $

(3) $b = r'+Nk' : 0<r'<N \rightarrow r'=b \text{ mod } N $

Summing (2) and (3) we get:

(4) $a+b = r+r'+N(k+k') = r+r'+Nt$

This is very similar to (1), however, not equal since $0<(r+r')<2N$

Let us take the mod of $r+r'$ and insert (4):

$r+r'= \gamma +No$

$a+b-N(k+k')=\gamma + No \rightarrow $

$a+b =\gamma + N(k+k'+o)=\gamma+Nh : 0<\gamma<N$ , which is eq (1).

Therefore, $(a+b) \text{ mod } N = (a \text{ mod } N + b \text{ mod } N) \text{ mod }N$

Making $b=-b$

$(a-b) \text{ mod } N = (a \text{ mod } N + (-b) \text{ mod } N) \text{ mod }N$

Since $(-a) \text{ mod } N= N-a \text{ mod } N$,

$(a-b) \text{ mod } N = (a \text{ mod } N +N- b \text{ mod } N) \text{ mod }N$

And then, finally

$(a-b) \text{ mod } N = (a \text{ mod } N - b \text{ mod } N) \text{ mod }N$