Zulip Chat Archive

Stream: new members

Topic: help with proof strategy to show a mod b is unique


rzeta0 (Feb 11 2025 at 16:30):

I've been struggling with an MoP exercise and specifically struggling with the Lean aspects.

So I thought I'd get some sleep, and start afresh at the overall proof strategy.

If the proof strategy is sensible, then I'll be justified in struggling with the Lean implementation,

I'd welcome thoughts on the following proof strategy:


Task:

Let  aa and bb  be integers, with  b>0b>0. Let rr and ss  be integers, both in the range 0r<b0 \le r < b,  and 0s<b0 \le s < b both congruent to aa  modulo bb. Show that they are equal.

Strategy:

  1. Definitions tell us ar=bma - r = b \cdot m, and as=bna - s = b \cdot n for some integers m,nm, n.

  2. Algebra gives us rs=b(nm)r-s = b \cdot (n - m), re-arranged to the more useful rsb=nm\frac{r-s}{b}= n-m.

  3. We have 3 cases: rs<0r-s < 0, rs>0r-s > 0, rs=0r-s = 0. So this is a proof by cases.

  4. Since, by definition, rr and ss are both less than bb, then LHS rsb\frac{r-s}{b} has magnitude less than 1. The RHS nmn-m must be an integer, and so the LHS rsb\frac{r-s}{b} can only be zero.

That is, two of the three cases have been ruled out, leaving only rs=0r-s=0.


I think the "upcasting" to show the fraction must have magnitude less than 1 might be a challenge for me.

Dan Velleman (Feb 11 2025 at 20:20):

Here's a strategy that avoids cases: Show that b<rs<b-b < r - s < b. Then, since you have rs=b(nm)r - s = b \cdot (n - m), you can conclude b<b(nm)<b-b < b \cdot (n - m) < b. Deduce from this that 1<nm<1-1 < n - m < 1. But nmn - m is an integer, so it must be 0.

There is a proof similar to this in Section 7.3 of of How To Prove It with Lean.

rzeta0 (Feb 11 2025 at 20:32):

Thanks Dan - I will study this approach.

I was running into errors associated with division, so avoiding even division will be good too.

failed to synthesize instance
  HDiv ℤ ℤ ?m.163069

Aaron Liu (Feb 12 2025 at 00:21):

You should convert to Rat before introducing division, since dividing integers has rounding.

Dan Velleman (Feb 12 2025 at 00:27):

...Or avoid division altogether by looking for a theorem about canceling b from both sides of an inequality.

Ruben Van de Velde (Feb 12 2025 at 08:48):

There's lemmas like this, for example:
@loogle ?b * ?c < ?b

loogle (Feb 12 2025 at 08:48):

:search: lt_one_of_mul_lt_right, mul_lt_of_lt_one_right', and 4 more


Last updated: May 02 2025 at 03:31 UTC