Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit e8aa984

Browse files
committed
doc(int/modeq): add module doc and tidy (#7878)
1 parent 1b0e5ee commit e8aa984

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/data/int/modeq.lean

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,24 @@ Authors: Chris Hughes
66
import data.nat.modeq
77
import tactic.ring
88

9+
/-!
10+
11+
# Congruences modulo an integer
12+
13+
This file defines the equivalence relation `a ≡ b [ZMOD n]` on the integers, similarly to how
14+
`data.nat.modeq` defines them for the natural numbers. The notation is short for `modeq a b n`,
15+
which is defined to be `a % n = b % n` for integer `a b n`.
16+
17+
## Tags
18+
19+
modeq, congruence, mod, MOD, modulo, integers
20+
21+
-/
22+
923
namespace int
1024

1125
/-- `a ≡ b [ZMOD n]` when `a % n = b % n`. -/
26+
@[derive decidable]
1227
def modeq (n a b : ℤ) := a % n = b % n
1328

1429
notation a ` ≡ `:50 b ` [ZMOD `:50 n `]`:0 := modeq n a b
@@ -25,8 +40,6 @@ variables {n m a b c d : ℤ}
2540
lemma coe_nat_modeq_iff {a b n : ℕ} : a ≡ b [ZMOD n] ↔ a ≡ b [MOD n] :=
2641
by unfold modeq nat.modeq; rw ← int.coe_nat_eq_coe_nat_iff; simp [int.coe_nat_mod]
2742

28-
instance : decidable (a ≡ b [ZMOD n]) := by unfold modeq; apply_instance
29-
3043
theorem modeq_zero_iff : a ≡ 0 [ZMOD n] ↔ n ∣ a :=
3144
by rw [modeq, zero_mod, dvd_iff_mod_eq_zero]
3245

@@ -106,10 +119,9 @@ calc a + n*c ≡ b + n*c [ZMOD n] : int.modeq.modeq_add ha (int.modeq.refl _)
106119
(int.modeq.modeq_zero_iff.2 (dvd_mul_right _ _))
107120
... ≡ b [ZMOD n] : by simp
108121

109-
open nat
110-
lemma mod_coprime {a b : ℕ} (hab : coprime a b) : ∃ y : ℤ, a * y ≡ 1 [ZMOD b] :=
122+
lemma mod_coprime {a b : ℕ} (hab : nat.coprime a b) : ∃ y : ℤ, a * y ≡ 1 [ZMOD b] :=
111123
⟨ nat.gcd_a a b,
112-
have hgcd : nat.gcd a b = 1, from coprime.gcd_eq_one hab,
124+
have hgcd : nat.gcd a b = 1, from nat.coprime.gcd_eq_one hab,
113125
calc
114126
↑a * nat.gcd_a a b ≡ ↑a * nat.gcd_a a b + ↑b * nat.gcd_b a b [ZMOD ↑b] : int.modeq.symm $
115127
modeq_add_fac _ $ int.modeq.refl _

0 commit comments

Comments
 (0)