3
$\begingroup$

If I have an expression such as $$ x = ((a \bmod b) - s) \bmod t, \quad 0 < a < b $$ And I want to step to $$ x = (a - s) \bmod t $$

Is acceptable to jump straight from the first expression to the second? Is there a law or rule I should site when eliminating the mod?

$\endgroup$
2
  • $\begingroup$ Think about what mod means, especially what $a$ mod $b$ means when $0<a<b$ $\endgroup$
    – Silynn
    Jun 12, 2014 at 2:59
  • 1
    $\begingroup$ I know it's redundant.. I want a valid way to show that knowledge in a proof. $\endgroup$
    – jsj
    Jun 12, 2014 at 3:00

2 Answers 2

1
$\begingroup$

The usual way the mod function is computed gives a result in $[0,b)$. Since $a$ is already in that range, $a \mod b=a$. You should write "$a \mod b=a$ since $0<a<b$".

$\endgroup$
3
  • $\begingroup$ Maybe my question is unclear. I understand that $a \bmod b = a$ if $0 <= a <b$. My question is whether it is okay to just remove the $\bmod$ operation in the proof, without any text or anything explaining why I removed it? $\endgroup$
    – jsj
    Jun 12, 2014 at 3:04
  • $\begingroup$ You should write "$a \mod b=a$ since $0<a<b$" as justification for this step. $\endgroup$
    – vadim123
    Jun 12, 2014 at 3:05
  • $\begingroup$ You don't lose anything by explaining more. If you're not sure of the step, then it needs an explanation. $\endgroup$
    – Ivo Terek
    Jun 12, 2014 at 3:08
0
$\begingroup$

Let us use the definition $r = a \bmod b$ is the remainder when $a$ is divided by $b$ (so $0 \leq r < b$ (without the loss of generality we can assume that $b>0$)). Then $$a=bq+r \qquad \text{with } 0 \leq r < b.$$

In your expression let $w= a \bmod b$, then $a=bq+w$. Since we are given that $0 < a <b$, therefore $q=0$, which implies $w=a$. Thus $$x= ((a \bmod b)-s )\bmod t= (w-s )\bmod t=(a-s) \bmod t.$$

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .