2

I am having trouble understanding division in modular arithmetic. I didn't manage to find any good resources online on that.

Usually it is explained like this:

If we have $a \equiv b$ (mod $n$) with $a = ka'$ and $b = kb'$. Then by definition we have $k(a' - b') = qn$ for some integer $q$. Then they say that from this last equation we are sure that $n$ divides $(a' - b')$, but not $k$. Why is that?

Also it is said that one should divide $n$ with the $GCD(n,k)$, but I can not see how that comes into play.

Can anyone show modular division more generally or provide a good resource to study it?

3 Answers3

4

$\begin{align} \bmod n&\!:\ kx\equiv ka\\[.2em] \iff\ \ \ \, n&\mid k\,(x-a)\\[.2em] \iff \color{#c00}{n/d}&\mid (\color{#c00}{k/d})(x-a),\ \ {\rm by\ cancelling}\ \ d = \gcd(n,k)\ \ {\rm from\ prior}\\[.2em] \iff n/d&\mid x-a,\ \ {\rm by}\ \ {\rm Euclid's\ Lemma}\ \ \&\ \gcd(\color{#c00}{n/d,k/d}) = \gcd(n,k)/d = \color{#c00}1\\[.2em] \iff \bmod n/d&\!:\, x\equiv a \end{align}$

Bill Dubuque
  • 282,220
  • I lose you at the third step. Where does that GCD come from? What is the reasoning for it? – Michael Munta Feb 16 '19 at 07:52
  • Specifically I am confused with the explanation on the following link: https://crypto.stanford.edu/pbc/notes/numbertheory/arith.html – Michael Munta Feb 16 '19 at 14:46
  • @Michael We cancelled $,d\neq 0,,$ in the prior, i.e. we used $, bd\mid cd\iff b\mid c\ \ $ – Bill Dubuque Feb 16 '19 at 18:03
  • @Michael The linked proof is essentially a less rigorous presentation of the proof I gave above. Neither are the same as the proof alluded to in your question. Where is that proof? The reason we cancel the gcd is this forces the new coef $k/d$ of $x$ to be coprime to the new modulus $n/d$ so the new coef is now invertible so cancellable, i.e. the goal is to reduce to this simpler case. Look at the special case $a=0$ in the answer. – Bill Dubuque Feb 16 '19 at 19:57
  • From the link in comments 'Then $n/d$ divides $z1−z2$ since it cannot divide $y$' it really should be that it cannot divide $y/d$, right? – Michael Munta Feb 16 '19 at 20:03
  • @Michael Yes, that proof is incorrect. A correct way is to use $,(n/d,y/d) = (n,y)/d = 1$ and Euclid's Lemma - as I did above. – Bill Dubuque Feb 16 '19 at 20:13
  • Ok, I understand. What about the special case $a = 0$? It just means that $n/d | x$? – Michael Munta Feb 16 '19 at 20:19
  • @Michael Just that it makes the proof slightly simpler since $a$ plays no essential role (we can always reduce to that case $a=0$ by replacing $,x-a,$ by $X).\ $ If you know linear algebra then you can view this as computing the kernel of the linear map $, x\to kx,\ $ which is $,(n/d)\Bbb Z.,$ Then the general solution of $,kx-ka \equiv 0,$ is the sum of the particular solution $x\equiv a$ plus said kernel (= general solution of the homogeneous equation $kx\equiv 0)\ $ – Bill Dubuque Feb 16 '19 at 20:30
  • @Michael Any linear equation has the same structure for its solution space, e.g. see here and its links. – Bill Dubuque Feb 16 '19 at 20:36
  • @MichaelMunta Here I discuss this result in fractional language. – Bill Dubuque Mar 17 '19 at 22:23
  • What is the reason you have added this additional equality in the 4th line? $$ \gcd(n/d,k/d) = \color{green}{ \gcd(n,k)/d } = 1$$ The green one. – Michael Munta Aug 06 '19 at 19:34
  • @Michael We need that gcd to be $1$ to apply Euclid's Lemma. That line is a proof using the GCD Distributive Law, e.g. see here. – Bill Dubuque Aug 06 '19 at 19:53
  • It seems trivial, why would you write that? It is just $d/d=1$. – Michael Munta Aug 07 '19 at 04:44
  • @MichaelMunta The first (nontrivial) equality (gcd distributive law) reduces it to that trivial 2nd equality – Bill Dubuque Aug 07 '19 at 12:29
  • How? Can you show it? – Michael Munta Aug 07 '19 at 16:44
  • @Michael It's the first equation in the prior-linked post. – Bill Dubuque Aug 07 '19 at 16:47
  • I have seen it but I don't see how to get specifically $d/d$? – Michael Munta Aug 07 '19 at 17:03
  • Can you please show me how to get that? Can't see the connection with that first equation. – Michael Munta Aug 08 '19 at 04:45
  • @Michael I added a note "more concisely" to the answer I linked (it's just a more concise rearrangement of the proof above it by cancelling $c).,$ Note that above $, d:=\gcd(n,k),$ so $,\gcd(n,k)/d = d/d = 1\ \ $ – Bill Dubuque Aug 09 '19 at 13:21
  • Hmm, yes, but how do you cancel $c$? – Michael Munta Aug 09 '19 at 19:08
  • @Michael $\ c = nc,\Rightarrow, 1 = n,,$ where $,n = (a/c,b/c),$ in the linked answer (here we know $,c\neq 0).,$ You can write $, c = c\cdot 1,$ if that makes the cancellation of $,c,$ clearer. – Bill Dubuque Aug 09 '19 at 19:14
  • So in the "more concisely" note the $x$ of the distributive law definition is actually $1/c$ whereas above it is just $c$. So the difference is just in whether we multiply or divide to factor out $x$. Is that about right? – Michael Munta Aug 15 '19 at 07:43
  • @Michael No, the application of the distributive law there is $,(a/c,b/c)c = (a,b),$ which is then transformed to $,(a/c,b/c) =(a,b)/c,$ by cancelling $,c.,$ With hindsight we could view that as an extension of the distributive law to fractional factors (above $1/c),$ but that would require proving an extension of the distributive law (and gcds) to handle fractions (it can be done but is best learned after one has mastered the basics) – Bill Dubuque Aug 15 '19 at 18:40
  • @Michael Note also that above we have $,c\mid a,b,$ so $,a/c,b/c,$ denote integers (not fractions), i.e. fractions don't occur anywhere above. The argument could be understood even before one leaned about fractions. – Bill Dubuque Aug 15 '19 at 18:47
  • But if distributive law specifies $(ax,bx)=(a,b)x$ then the second line goes from $(ax,bx)$ to $(a,b)x$. How to interpret the $x$ that gets factored out then? – Michael Munta Aug 16 '19 at 06:27
  • Or the second line is not even the application of the law, just dividing both sides of the first equation by $c$ where we initially applied it? – Michael Munta Aug 16 '19 at 06:34
  • @Michael Yes, apply the law then cancel $c$. With care. you can also think of this cancelled form as another form of the distributive law. – Bill Dubuque Aug 16 '19 at 12:15
  • You mean think of it as distributing division instead of multiplication? – Michael Munta Aug 16 '19 at 13:51
  • @Michael Yes - with care - we can view it that way. – Bill Dubuque Aug 16 '19 at 14:02
1

I will give you a proof that was very easy for me to understand when I was first studying congruences.

From $a \equiv b \text{ (mod } n)$ it follows that $a-b=qn$ for some $q \in \mathbb{Z}$. Dividing both sides by $k$ we get $$a'-b'=q \cdot \frac{n}{k}$$ If we write $n$ and $k$ as $n=\text{GCD(}n,k)\cdot n_1$ and $k=\text{GCD(}n,k)\cdot k_1$, then we get $$a'-b'=q \cdot \frac{\text{GCD(}n,k)\cdot n_1}{\text{GCD(}n,k)\cdot k_1} = q \cdot \frac{n_1}{k_1}$$

Since $n_1$ and $k_1$ are mutually prime ($\text{GCD(}n_1,k_1)=1$) and we know that $a'-b'$ must be an integer, we conclude that $k_1 | q$ and $\frac{q}{k_1}$ is an integer.

Thus, $a'-b'=\frac{q}{k_1}\cdot n_1$ which is equivalent to $$a' \equiv b' \text{ (mod } \frac{n}{\text{GCD(}n,k)})$$

To illustrate why the division by GCD is necessary I will show an example. Let $a=6, b=12, n=2$. We have the congruence $$6 \equiv 12 \text{ (mod } 2)$$ which is the same as $6-12=-3 \cdot 2$. We can see that $q=-3$. Now, if we divide both sides with $k=2$, we get $3-6=-3$, and $2\not|-3$.

Therefore, the congruence $3 \equiv 6 \text{ (mod } 2)$ does not hold.

  • What if $k_1$ turns out to be $1$ meaning that we can divide $n$ by $k$? Also I think you have a mistake in your last 2 sentences, shouldn't it be $\frac{q}{k_1}$? – Michael Munta Feb 15 '19 at 12:19
  • @MichaelMunta You are right, it was a mistake and I corrected it. If $k_1=1$ then $q/k_1$ is an integer anyway. We get a convergence modulo 1 which holds trivially. – Haris Gušić Feb 15 '19 at 12:32
  • In your example though it is correct in modulo $1$, isn't it? I suppose you were only showing me the proof where division is defined in the same modulo? – Michael Munta Feb 15 '19 at 13:16
  • @MichaelMunta The example is indeed correct with modulo 1. What do you mean by "division is defined in the same modulo"? – Haris Gušić Feb 15 '19 at 13:21
  • I meant that sometimes we can divide both sides of the congruence and get the correct congruence in the same modulo, but sometimes we have to divide the modulo as well so we get the result in a different modulo. – Michael Munta Feb 15 '19 at 13:27
  • @MichaelMunta Yes, of course. There are always special cases. I am just saying that the starting congruence is not enough to make any such conclusions. You would need to know more about $a$ and $b$ thenselves. – Haris Gušić Feb 15 '19 at 13:36
  • I am still struggling to understand why GCD is necessary here. We know that both sides of the equation will be divisible by $k$, so why do we have to do that with GCD? – Michael Munta Feb 16 '19 at 16:46
0

This is a useful link

I have made some rough calculations assuming $a,b$ both non zero, this may help you. As given $a\equiv b(\mod n)$ so clearly $b<a$ as all are natural numbers further the residue of the division implies $n \not | a$.

If possible suppose that, $n|k$ where $a=ka',b=kb'$ as defined in your problem. Then $n|ka'\implies n|a$ this contradicts the above mentioned fact.

For the second one, we see that $gcd(k,\frac{n}{gcd(n,k)})=1$ provided $gcd(n,k)\ne 1$, then the quantity $\frac{n}{gcd(n,k)}$ is relatively prime to $k$ and hence doesnot divide $k$.

Hope this works.