Title: Very simple question, but what is the proof that x.y mod m == ((x mod m).y) mod m?
Tags: modular-arithmetic
Question: I apologise for this question, as it is no doubt very simple, but I've never been very confident with proofs. Our lecturer today (in a course related to maths but not mathematical itself) was playing with doing the modulus of powers, and used the above fact - $(x.y)\; mod\; m\; ==\; ((x\; mod\; m).y)\; mod\; m$ - to show a quick way to do it. She mentioned offhand that the proof was short and easy, and that we should try it. Well, I did. And I'm not really sure that what I've done is mathematically sound. So I'd very much appreciate it if anyone could give me some help with how to do this proof correctly - googling for it turned up many pages which just state it as simple fact. I would not call my proof short or easy, so I reckon I've just got completely the wrong end of the stick.
My proof:
When considering any number, denoted n, in regards to another number m, we can write it as $n_b$ + $n_r$, where the former is some multiple of m, and the latter is the remainder when you take n mod m.
If we expand the original formula, $(x.y)\; mod\; m$ like this, we get $((x_b + x_r)(y_b + y_r))\; mod\; m$. This then expands to $(x_b y_b + x_b y_r + x_r y_b + x_r y_r)\; mod\; m$. The first three terms in the brackets are all some multiple of m, and so when they are taken modulus m they are 0. The final term we do not know, so we are left with: $(x_r y_r)\; mod\; m$.
Now we can consider the left hand side. $((x\; mod\; m).y)\; mod\; m$ is equivalent to $((x_r).y)\; mod\; m$. Expanding y gives us: $((x_r)(y_b + y_r))\; mod\; m$. Multiplying out then gives $(x_r y_b + x_r y_r)\; mod\; m$. As before, the first term in the brackets are multiples of m and so are 0 when taken mod m, and the last one we do not know, so we are left with: $(x_r y_r)\; mod\; m$.
Since both the LHS and RHS boil down to the same thing, the equality holds.


Here is another answer: I guess you already know how to prove that (s+t) mod m = ((s mod m)+(t mod m)) mod m.  If not, you should first prove it, because you are using it in your proof.  Other than this, your proof is correct except for a tiny point that you have not stated what yb and yr are.
I call your proof easy, but slightly verbose.  Most importantly, you do not have to break y into yb and yr.
Comment for this answer: @Andrew: Your argument about addition is basically correct, except that when you stated “$s_r+t_r$ bigger than a modulus of m,” you probably meant “$s_r+t_r$ plus some multiple of m.”  It takes some practice to write an proof in a concise way, though.  The biggest source of verbosity here is that you are trying to prove an equation and _motivate_ it at the same time.  You do not always have to motivate the formula to prove.  (more)
Comment for this answer: @Andrew: (cont’d)  Namely, you do not have to explain why “we _need to_ take it mod m again” in a proof; all you have to do is to prove that a given formula is correct.  (Thinking about why we have to take mod m again is a good thing, but it is often better not to mix this consideration with a proof.)
Comment for this answer: Thank you for your note about $y_b$ and $y_r$. I have edited the definition to be more general. I also am having trouble proving the addition bit - I can write it in words quite easily but struggle to do it mathematically (Adding s and t gives you a number that is $(s_b + s_r + t_b + t_r)$, which is a number that is $s_r + t_r$ bigger than a modulus of m. Since $s_r + t_r$ may be bigger than m, we need to take it mod m again. The right hand side boils down to the same thing, and so etc etc.)
Comment for this answer: Sorry, yes, I meant to say that $s_r + t_r$ may be bigger than m (we know that individually they are smaller, but their sum may be bigger) and so they must be taken modular m to get the correct answer. I will try and work on the difference between proving and motivation. Thank you for your help. I am just glad I had the correct understanding of the proof in general.

Here is another answer: Below are proofs of the product rule proof expressed in both divisibility and congruence form, using the standard notation: $\rm\  \ a\ |\ b \ :=\ a\,$ divides $\rm\, b\:,\;$ and $\rm\ \; a\equiv b\ \ (mod\ m)\: \iff\: m\:|\:a-b$
$\begin{eqnarray}
\rm {\bf Lemma}\ \   &amp;\rm m\ \ |&amp;\rm\ \, X-x\quad\ and &amp;&amp;\rm m\ |\: Y-y \ \Rightarrow\ m\:|\!\!&amp;&amp;\rm XY - \: xy\\ \\
\rm {\bf Proof}\ \ \ \ \ &amp;\rm m\ \ |&amp;\rm (X-\color{#C00}x)\:\color{#C00}Y\ \ \ +   &amp;&amp;\rm\, \color{#C00}x\ (\color{#C00}Y-y)\ \ \ = &amp;&amp;\rm XY - \: xy \\
\rm {\bf Lemma}\ \ &amp;         &amp;\rm\ \, X\equiv x\quad\ \ and &amp;&amp;\rm\quad\ \ Y\equiv y \ \ \ \ \Rightarrow\ &amp;&amp;\rm XY\equiv xy\\ \\
\rm {\bf Proof}\ \ \ \ \ &amp;0\equiv&amp; \rm (X-\color{#C00}x)\:\color{#C00}Y\ \ \ + &amp;&amp;\rm\, \color{#C00}x\ (\color{#C00}Y-y)\ \ \ \equiv &amp;&amp;\rm XY - \: xy \\
\end{eqnarray}$
Note how the congruence notation eliminates  cumbersome manipulation of relations (divisibility). Indeed, the relations are replaced by a generalized equality (congruence) which, being compatible with multiplication (as above) and addition (similar proof), enables us to exploit our well-honed intuition manipulating integer equations - which immediately generalizes to manipulating congruences (mod m). When you study abstract algebra you'll learn that this is a very special case of a quotient or residue ring. This product rule arises in many analogous contexts, e.g. see my post on the product rule for derivatives.

{'source': 'StackExchangeDataset', 'subset': 'math.stackexchange.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 2.5', 'CreationDate': '2010:00:09/24/10', 'FavoriteCount': 2.0, 'PostTypeId': 1, 'Tags': '<modular-arithmetic>', 'Title': 'Very simple question, but what is the proof that x.y mod m == ((x mod m).y) mod m?', 'ViewCount': 6647, 'id': 5366, 'user_AboutMe': None, 'user_AccountId': None, 'user_DisplayName': None, 'user_Reputation': None, 'user_Views': None, 'user_id': None}}