Zulip Chat Archive

Stream: mathlib4

Topic: About the type of the arguments for Int.mod_coprime


Kevin Cheung (Jul 03 2025 at 11:04):

I saw that Int.mod_coprime has type Nat for the arguments a and b:

theorem Int.mod_coprime{a b : } (hab : a.Coprime b) :
 (y : ), a * y  1 [ZMOD b]

Since this theorem is under Mathlib.Data.Int.ModEq, I was expecting that a and b would be Int. Is such an expectation reasonable?

Also, would a Nat version look like the following?

theorem Nat.mod_coprime{a b : } (hab : a.Coprime b) :
 y , a * y  1 [MOD b]

Aaron Liu (Jul 03 2025 at 11:57):

docs#Int.mod_coprime

Aaron Liu (Jul 03 2025 at 11:58):

I don't like this because it doesn't follow the naming convention

Kevin Cheung (Jul 03 2025 at 12:06):

How should this be fixed?

Ruben Van de Velde (Jul 03 2025 at 12:41):

Fwiw, this works:

import Mathlib

open Int

theorem mod_coprime {a b : } (hab : IsCoprime a b) :  y : , a * y  1 [ZMOD b] :=
  Int.gcdA a b,
    have hgcd : Int.gcd a b = 1 := Int.isCoprime_iff_gcd_eq_one.mp hab
    calc
      a * Int.gcdA a b  a * Int.gcdA a b + b * Int.gcdB a b [ZMOD b] :=
        ModEq.symm <| modEq_add_fac _ <| ModEq.refl _
      _  1 [ZMOD b] := by rw [ Int.gcd_eq_gcd_ab, hgcd, Nat.cast_one]
      

Kevin Cheung (Jul 03 2025 at 15:16):

Thanks @Ruben Van de Velde . Will you make this change for a future release of Mathlib?

Ruben Van de Velde (Jul 03 2025 at 16:02):

I wasn't planning to, but anyone should feel free :)


Last updated: Dec 20 2025 at 21:32 UTC