Skip to content

Commit 96ac52f

Browse files
committed
chore(*.ModEq): reduce dependencies (#17154)
Both `Nat.ModEq` and `Int.ModEq` have some spurious dependencies which can be removed by reasonable swaps of generic tactics/declarations for `Nat` and `Int` native versions (e.g. use `omega` more). This PR does that and makes a slouching attempt to hold back the import graph downstream of these. Co-authored-by: Matthew Robert Ballard <100034030+mattrobball@users.noreply.github.com>
1 parent 3a0cb01 commit 96ac52f

File tree

11 files changed

+54
-56
lines changed

11 files changed

+54
-56
lines changed

Mathlib/Algebra/CharP/Defs.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Mathlib.Data.Nat.Cast.Prod
1111
import Mathlib.Data.Nat.Find
1212
import Mathlib.Data.Nat.Prime.Defs
1313
import Mathlib.Data.ULift
14+
import Mathlib.Tactic.NormNum.Basic
1415

1516
/-!
1617
# Characteristic of semirings
@@ -102,10 +103,10 @@ lemma intCast_injOn_Ico [IsRightCancelAdd R] : InjOn (Int.cast : ℤ → R) (Ico
102103

103104
lemma intCast_eq_zero_iff (a : ℤ) : (a : R) = 0 ↔ (p : ℤ) ∣ a := by
104105
rcases lt_trichotomy a 0 with (h | rfl | h)
105-
· rw [← neg_eq_zero, ← Int.cast_neg, ← dvd_neg]
106+
· rw [← neg_eq_zero, ← Int.cast_neg, ← Int.dvd_neg]
106107
lift -a to ℕ using neg_nonneg.mpr (le_of_lt h) with b
107108
rw [Int.cast_natCast, CharP.cast_eq_zero_iff R p, Int.natCast_dvd_natCast]
108-
· simp only [Int.cast_zero, eq_self_iff_true, dvd_zero]
109+
· simp only [Int.cast_zero, eq_self_iff_true, Int.dvd_zero]
109110
· lift a to ℕ using le_of_lt h with b
110111
rw [Int.cast_natCast, CharP.cast_eq_zero_iff R p, Int.natCast_dvd_natCast]
111112

Mathlib/Algebra/ModEq.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Authors: Yaël Dillies
55
-/
66
import Mathlib.Data.Int.ModEq
77
import Mathlib.Algebra.Field.Basic
8+
import Mathlib.Algebra.Order.Ring.Int
89
import Mathlib.GroupTheory.QuotientGroup.Basic
910

1011
/-!

Mathlib/Algebra/Order/Group/Unbundled/Int.lean

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ theorem abs_le_one_iff {a : ℤ} : |a| ≤ 1 ↔ a = 0 ∨ a = 1 ∨ a = -1 := b
8282
theorem one_le_abs {z : ℤ} (h₀ : z ≠ 0) : 1 ≤ |z| :=
8383
add_one_le_iff.mpr (abs_pos.mpr h₀)
8484

85+
lemma eq_zero_of_abs_lt_dvd {m x : ℤ} (h1 : m ∣ x) (h2 : |x| < m) : x = 0 := by
86+
by_contra h
87+
have := Int.natAbs_le_of_dvd_ne_zero h1 h
88+
rw [Int.abs_eq_natAbs] at h2
89+
omega
90+
91+
lemma abs_sub_lt_of_lt_lt {m a b : ℕ} (ha : a < m) (hb : b < m) : |(b : ℤ) - a| < m := by
92+
rw [abs_lt]; omega
93+
8594
/-! #### `/` -/
8695

8796
theorem ediv_eq_zero_of_lt_abs {a b : ℤ} (H1 : 0 ≤ a) (H2 : a < |b|) : a / b = 0 :=

Mathlib/Combinatorics/Additive/FreimanHom.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Mathlib.Algebra.CharP.Defs
88
import Mathlib.Algebra.Group.Pointwise.Set.Basic
99
import Mathlib.Algebra.Group.Submonoid.Operations
1010
import Mathlib.Algebra.Order.BigOperators.Group.Multiset
11+
import Mathlib.Algebra.Order.Ring.Nat
1112
import Mathlib.Data.ZMod.Defs
1213

1314
/-!

Mathlib/Data/Int/ModEq.lean

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Chris Hughes
55
-/
66
import Mathlib.Data.Nat.ModEq
7-
import Mathlib.Tactic.Abel
8-
import Mathlib.Tactic.GCongr.CoreAttrs
97

108
/-!
119
@@ -92,8 +90,7 @@ theorem mod_modEq (a n) : a % n ≡ a [ZMOD n] :=
9290

9391
@[simp]
9492
theorem neg_modEq_neg : -a ≡ -b [ZMOD n] ↔ a ≡ b [ZMOD n] := by
95-
-- Porting note: Restore old proof once #3309 is through
96-
simp [-sub_neg_eq_add, neg_sub_neg, modEq_iff_dvd, dvd_sub_comm]
93+
simp only [modEq_iff_dvd, (by omega : -b - -a = -(b - a)), Int.dvd_neg]
9794

9895
@[simp]
9996
theorem modEq_neg : a ≡ b [ZMOD -n] ↔ a ≡ b [ZMOD n] := by simp [modEq_iff_dvd]
@@ -105,17 +102,17 @@ protected theorem of_dvd (d : m ∣ n) (h : a ≡ b [ZMOD n]) : a ≡ b [ZMOD m]
105102

106103
protected theorem mul_left' (h : a ≡ b [ZMOD n]) : c * a ≡ c * b [ZMOD c * n] := by
107104
obtain hc | rfl | hc := lt_trichotomy c 0
108-
· rw [← neg_modEq_neg, ← modEq_neg, ← neg_mul, ← neg_mul, ← neg_mul]
105+
· rw [← neg_modEq_neg, ← modEq_neg, ← Int.neg_mul, ← Int.neg_mul, ← Int.neg_mul]
109106
simp only [ModEq, mul_emod_mul_of_pos _ _ (neg_pos.2 hc), h.eq]
110-
· simp only [zero_mul, ModEq.rfl]
107+
· simp only [Int.zero_mul, ModEq.rfl]
111108
· simp only [ModEq, mul_emod_mul_of_pos _ _ hc, h.eq]
112109

113110
protected theorem mul_right' (h : a ≡ b [ZMOD n]) : a * c ≡ b * c [ZMOD n * c] := by
114111
rw [mul_comm a, mul_comm b, mul_comm n]; exact h.mul_left'
115112

116113
@[gcongr]
117114
protected theorem add (h₁ : a ≡ b [ZMOD n]) (h₂ : c ≡ d [ZMOD n]) : a + c ≡ b + d [ZMOD n] :=
118-
modEq_iff_dvd.2 <| by convert dvd_add h₁.dvd h₂.dvd using 1; abel
115+
modEq_iff_dvd.2 <| by convert Int.dvd_add h₁.dvd h₂.dvd using 1; omega
119116

120117
@[gcongr] protected theorem add_left (c : ℤ) (h : a ≡ b [ZMOD n]) : c + a ≡ c + b [ZMOD n] :=
121118
ModEq.rfl.add h
@@ -125,10 +122,10 @@ protected theorem add (h₁ : a ≡ b [ZMOD n]) (h₂ : c ≡ d [ZMOD n]) : a +
125122

126123
protected theorem add_left_cancel (h₁ : a ≡ b [ZMOD n]) (h₂ : a + c ≡ b + d [ZMOD n]) :
127124
c ≡ d [ZMOD n] :=
128-
have : d - c = b + d - (a + c) - (b - a) := by abel
125+
have : d - c = b + d - (a + c) - (b - a) := by omega
129126
modEq_iff_dvd.2 <| by
130127
rw [this]
131-
exact dvd_sub h₂.dvd h₁.dvd
128+
exact Int.dvd_sub h₂.dvd h₁.dvd
132129

133130
protected theorem add_left_cancel' (c : ℤ) (h : c + a ≡ c + b [ZMOD n]) : a ≡ b [ZMOD n] :=
134131
ModEq.rfl.add_left_cancel h
@@ -183,7 +180,7 @@ theorem cancel_right_div_gcd (hm : 0 < m) (h : a * c ≡ b * c [ZMOD m]) :
183180
rw [modEq_iff_dvd] at h ⊢
184181
-- Porting note: removed `show` due to leanprover-community/mathlib4#3305
185182
refine Int.dvd_of_dvd_mul_right_of_gcd_one (?_ : m / d ∣ c / d * (b - a)) ?_
186-
· rw [mul_comm, ← Int.mul_ediv_assoc (b - a) gcd_dvd_right, sub_mul]
183+
· rw [mul_comm, ← Int.mul_ediv_assoc (b - a) gcd_dvd_right, Int.sub_mul]
187184
exact Int.ediv_dvd_ediv gcd_dvd_left h
188185
· rw [gcd_div gcd_dvd_left gcd_dvd_right, natAbs_ofNat,
189186
Nat.div_self (gcd_pos_of_ne_zero_left c hm.ne')]
@@ -233,7 +230,7 @@ theorem modEq_add_fac {a b n : ℤ} (c : ℤ) (ha : a ≡ b [ZMOD n]) : a + n *
233230
_ ≡ b [ZMOD n] := by rw [add_zero]
234231

235232
theorem modEq_sub_fac {a b n : ℤ} (c : ℤ) (ha : a ≡ b [ZMOD n]) : a - n * c ≡ b [ZMOD n] := by
236-
convert Int.modEq_add_fac (-c) ha using 1; rw [mul_neg, sub_eq_add_neg]
233+
convert Int.modEq_add_fac (-c) ha using 1; rw [Int.mul_neg, sub_eq_add_neg]
237234

238235
theorem modEq_add_fac_self {a t n : ℤ} : a + n * t ≡ a [ZMOD n] :=
239236
modEq_add_fac _ ModEq.rfl

Mathlib/Data/Int/Order/Lemmas.lean

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,4 @@ theorem natAbs_le_iff_mul_self_le {a b : ℤ} : a.natAbs ≤ b.natAbs ↔ a * a
3434
rw [← abs_le_iff_mul_self_le, abs_eq_natAbs, abs_eq_natAbs]
3535
exact Int.ofNat_le.symm
3636

37-
/-! ### units -/
38-
39-
40-
theorem eq_zero_of_abs_lt_dvd {m x : ℤ} (h1 : m ∣ x) (h2 : |x| < m) : x = 0 := by
41-
obtain rfl | hm := eq_or_ne m 0
42-
· exact Int.zero_dvd.1 h1
43-
rcases h1 with ⟨d, rfl⟩
44-
apply mul_eq_zero_of_right
45-
rw [← abs_lt_one_iff, ← mul_lt_iff_lt_one_right (abs_pos.mpr hm), ← abs_mul]
46-
exact lt_of_lt_of_le h2 (le_abs_self m)
47-
4837
end Int

Mathlib/Data/Nat/ModEq.lean

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ Copyright (c) 2017 Mario Carneiro. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Mario Carneiro
55
-/
6-
import Mathlib.Algebra.Ring.Regular
6+
import Mathlib.Algebra.Order.Group.Unbundled.Int
77
import Mathlib.Data.Int.GCD
8-
import Mathlib.Data.Int.Order.Lemmas
9-
import Mathlib.Tactic.NormNum.Basic
108

119
/-!
1210
# Congruences modulo a natural number
@@ -24,6 +22,7 @@ and proves basic properties about it such as the Chinese Remainder Theorem
2422
ModEq, congruence, mod, MOD, modulo
2523
-/
2624

25+
assert_not_exists OrderedAddCommMonoid
2726
assert_not_exists Function.support
2827

2928
namespace Nat
@@ -37,8 +36,8 @@ notation:50 a " ≡ " b " [MOD " n "]" => ModEq n a b
3736

3837
variable {m n a b c d : ℕ}
3938

40-
-- Porting note: This instance should be derivable automatically
41-
instance : Decidable (ModEq n a b) := decEq (a % n) (b % n)
39+
-- Since `ModEq` is semi-reducible, we need to provide the decidable instance manually
40+
instance : Decidable (ModEq n a b) := inferInstanceAs <| Decidable (a % n = b % n)
4241

4342
namespace ModEq
4443

@@ -91,7 +90,7 @@ theorem mod_modEq (a n) : a % n ≡ a [MOD n] :=
9190
namespace ModEq
9291

9392
lemma of_dvd (d : m ∣ n) (h : a ≡ b [MOD n]) : a ≡ b [MOD m] :=
94-
modEq_of_dvd <| d.natCast.trans h.dvd
93+
modEq_of_dvd <| Int.ofNat_dvd.mpr d |>.trans h.dvd
9594

9695
protected theorem mul_left' (c : ℕ) (h : a ≡ b [MOD n]) : c * a ≡ c * b [MOD c * n] := by
9796
unfold ModEq at *; rw [mul_mod_mul_left, mul_mod_mul_left, h]
@@ -122,7 +121,7 @@ protected theorem pow (m : ℕ) (h : a ≡ b [MOD n]) : a ^ m ≡ b ^ m [MOD n]
122121
@[gcongr]
123122
protected theorem add (h₁ : a ≡ b [MOD n]) (h₂ : c ≡ d [MOD n]) : a + c ≡ b + d [MOD n] := by
124123
rw [modEq_iff_dvd, Int.ofNat_add, Int.ofNat_add, add_sub_add_comm]
125-
exact dvd_add h₁.dvd h₂.dvd
124+
exact Int.dvd_add h₁.dvd h₂.dvd
126125

127126
@[gcongr]
128127
protected theorem add_left (c : ℕ) (h : a ≡ b [MOD n]) : c + a ≡ c + b [MOD n] :=
@@ -136,7 +135,7 @@ protected theorem add_left_cancel (h₁ : a ≡ b [MOD n]) (h₂ : a + c ≡ b +
136135
c ≡ d [MOD n] := by
137136
simp only [modEq_iff_dvd, Int.ofNat_add] at *
138137
rw [add_sub_add_comm] at h₂
139-
convert _root_.dvd_sub h₂ h₁ using 1
138+
convert Int.dvd_sub h₂ h₁ using 1
140139
rw [add_sub_cancel_left]
141140

142141
protected theorem add_left_cancel' (c : ℕ) (h : c + a ≡ c + b [MOD n]) : a ≡ b [MOD n] :=
@@ -155,7 +154,8 @@ protected theorem add_right_cancel' (c : ℕ) (h : a + c ≡ b + c [MOD n]) : a
155154
For cancelling left multiplication in the modulus, see `Nat.ModEq.of_mul_left`. -/
156155
protected theorem mul_left_cancel' {a b c m : ℕ} (hc : c ≠ 0) :
157156
c * a ≡ c * b [MOD c * m] → a ≡ b [MOD m] := by
158-
simp [modEq_iff_dvd, ← mul_sub, mul_dvd_mul_iff_left (by simp [hc] : (c : ℤ) ≠ 0)]
157+
simp only [modEq_iff_dvd, Int.natCast_mul, ← Int.mul_sub]
158+
exact fun h => (Int.dvd_of_mul_dvd_mul_left (Int.ofNat_ne_zero.mpr hc) h)
159159

160160
protected theorem mul_left_cancel_iff' {a b c m : ℕ} (hc : c ≠ 0) :
161161
c * a ≡ c * b [MOD c * m] ↔ a ≡ b [MOD m] :=
@@ -166,7 +166,8 @@ protected theorem mul_left_cancel_iff' {a b c m : ℕ} (hc : c ≠ 0) :
166166
For cancelling right multiplication in the modulus, see `Nat.ModEq.of_mul_right`. -/
167167
protected theorem mul_right_cancel' {a b c m : ℕ} (hc : c ≠ 0) :
168168
a * c ≡ b * c [MOD m * c] → a ≡ b [MOD m] := by
169-
simp [modEq_iff_dvd, ← sub_mul, mul_dvd_mul_iff_right (by simp [hc] : (c : ℤ) ≠ 0)]
169+
simp only [modEq_iff_dvd, Int.natCast_mul, ← Int.sub_mul]
170+
exact fun h => (Int.dvd_of_mul_dvd_mul_right (Int.ofNat_ne_zero.mpr hc) h)
170171

171172
protected theorem mul_right_cancel_iff' {a b c m : ℕ} (hc : c ≠ 0) :
172173
a * c ≡ b * c [MOD m * c] ↔ a ≡ b [MOD m] :=
@@ -204,10 +205,10 @@ namespace ModEq
204205
theorem le_of_lt_add (h1 : a ≡ b [MOD m]) (h2 : a < b + m) : a ≤ b :=
205206
(le_total a b).elim id fun h3 =>
206207
Nat.le_of_sub_eq_zero
207-
(eq_zero_of_dvd_of_lt ((modEq_iff_dvd' h3).mp h1.symm) ((tsub_lt_iff_left h3).mpr h2))
208+
(eq_zero_of_dvd_of_lt ((modEq_iff_dvd' h3).mp h1.symm) (by omega))
208209

209210
theorem add_le_of_lt (h1 : a ≡ b [MOD m]) (h2 : a < b) : a + m ≤ b :=
210-
le_of_lt_add (add_modEq_right.trans h1) (add_lt_add_right h2 m)
211+
le_of_lt_add (add_modEq_right.trans h1) (by omega)
211212

212213
theorem dvd_iff (h : a ≡ b [MOD m]) (hdm : d ∣ m) : d ∣ a ↔ d ∣ b := by
213214
simp only [← modEq_zero_iff_dvd]
@@ -227,9 +228,7 @@ lemma eq_of_abs_lt (h : a ≡ b [MOD m]) (h2 : |(b : ℤ) - a| < m) : a = b := b
227228
exact Int.eq_zero_of_abs_lt_dvd h.dvd h2
228229

229230
lemma eq_of_lt_of_lt (h : a ≡ b [MOD m]) (ha : a < m) (hb : b < m) : a = b :=
230-
h.eq_of_abs_lt <| abs_sub_lt_iff.2
231-
⟨(sub_le_self _ <| Int.natCast_nonneg _).trans_lt <| Int.ofNat_lt.2 hb,
232-
(sub_le_self _ <| Int.natCast_nonneg _).trans_lt <| Int.ofNat_lt.2 ha⟩
231+
h.eq_of_abs_lt <| Int.abs_sub_lt_of_lt_lt ha hb
233232

234233
/-- To cancel a common factor `c` from a `ModEq` we must divide the modulus `m` by `gcd m c` -/
235234
lemma cancel_left_div_gcd (hm : 0 < m) (h : c * a ≡ c * b [MOD m]) : a ≡ b [MOD m / gcd m c] := by
@@ -241,7 +240,7 @@ lemma cancel_left_div_gcd (hm : 0 < m) (h : c * a ≡ c * b [MOD m]) : a ≡ b
241240
· show (m / d : ℤ) ∣ c / d * (b - a)
242241
rw [mul_comm, ← Int.mul_ediv_assoc (b - a) (Int.natCast_dvd_natCast.mpr hcd), mul_comm]
243242
apply Int.ediv_dvd_ediv (Int.natCast_dvd_natCast.mpr hmd)
244-
rw [mul_sub]
243+
rw [Int.mul_sub]
245244
exact modEq_iff_dvd.mp h
246245
· show Int.gcd (m / d) (c / d) = 1
247246
simp only [← Int.natCast_div, Int.gcd_natCast_natCast (m / d) (c / d), gcd_div hmd hcd,
@@ -299,18 +298,18 @@ def chineseRemainder' (h : a ≡ b [MOD gcd n m]) : { k // k ≡ a [MOD n] ∧ k
299298
have hcoedvd : ∀ t, (gcd n m : ℤ) ∣ t * (b - a) := fun t => h.dvd.mul_left _
300299
have := gcd_eq_gcd_ab n m
301300
constructor <;> rw [Int.emod_def, ← sub_add] <;>
302-
refine dvd_add ?_ (dvd_mul_of_dvd_left ?_ _) <;>
301+
refine Int.dvd_add ?_ (dvd_mul_of_dvd_left ?_ _) <;>
303302
try norm_cast
304303
· rw [← sub_eq_iff_eq_add'] at this
305-
rw [← this, sub_mul, ← add_sub_assoc, add_comm, add_sub_assoc, ← mul_sub,
304+
rw [← this, Int.sub_mul, ← add_sub_assoc, add_comm, add_sub_assoc, ← Int.mul_sub,
306305
Int.add_ediv_of_dvd_left, Int.mul_ediv_cancel_left _ hnonzero,
307-
Int.mul_ediv_assoc _ h.dvd, ← sub_sub, sub_self, zero_sub, dvd_neg, mul_assoc]
306+
Int.mul_ediv_assoc _ h.dvd, ← sub_sub, sub_self, zero_sub, Int.dvd_neg, mul_assoc]
308307
· exact dvd_mul_right _ _
309308
norm_cast
310309
exact dvd_mul_right _ _
311310
· exact dvd_lcm_left n m
312311
· rw [← sub_eq_iff_eq_add] at this
313-
rw [← this, sub_mul, sub_add, ← mul_sub, Int.sub_ediv_of_dvd,
312+
rw [← this, Int.sub_mul, sub_add, ← Int.mul_sub, Int.sub_ediv_of_dvd,
314313
Int.mul_ediv_cancel_left _ hnonzero, Int.mul_ediv_assoc _ h.dvd, ← sub_add, sub_self,
315314
zero_add, mul_assoc]
316315
· exact dvd_mul_right _ _
@@ -407,7 +406,7 @@ protected theorem add_div_of_dvd_right {a b c : ℕ} (hca : c ∣ a) : (a + b) /
407406
add_div_eq_of_add_mod_lt
408407
(by
409408
rw [Nat.mod_eq_zero_of_dvd hca, zero_add]
410-
exact Nat.mod_lt _ (pos_iff_ne_zero.mpr h))
409+
exact Nat.mod_lt _ (zero_lt_of_ne_zero h))
411410

412411
protected theorem add_div_of_dvd_left {a b c : ℕ} (hca : c ∣ b) : (a + b) / c = a / c + b / c := by
413412
rwa [add_comm, Nat.add_div_of_dvd_right, add_comm]
@@ -430,27 +429,24 @@ theorem odd_mul_odd {n m : ℕ} : n % 2 = 1 → m % 2 = 1 → n * m % 2 = 1 := b
430429

431430
theorem odd_mul_odd_div_two {m n : ℕ} (hm1 : m % 2 = 1) (hn1 : n % 2 = 1) :
432431
m * n / 2 = m * (n / 2) + m / 2 :=
433-
have hm0 : 0 < m := Nat.pos_of_ne_zero fun h => by simp_all
434432
have hn0 : 0 < n := Nat.pos_of_ne_zero fun h => by simp_all
435433
mul_right_injective₀ two_ne_zero <| by
436434
dsimp
437435
rw [mul_add, two_mul_odd_div_two hm1, mul_left_comm, two_mul_odd_div_two hn1,
438-
two_mul_odd_div_two (Nat.odd_mul_odd hm1 hn1), mul_tsub, mul_one, ←
439-
add_tsub_assoc_of_le (succ_le_of_lt hm0),
440-
tsub_add_cancel_of_le (le_mul_of_one_le_right (Nat.zero_le _) hn0)]
436+
two_mul_odd_div_two (Nat.odd_mul_odd hm1 hn1), Nat.mul_sub, mul_one, ←
437+
Nat.add_sub_assoc (by omega), Nat.sub_add_cancel (Nat.le_mul_of_pos_right m hn0)]
441438

442439
theorem odd_of_mod_four_eq_one {n : ℕ} : n % 4 = 1 → n % 2 = 1 := by
443-
simpa [ModEq, show 2 * 2 = 4 by norm_num] using @ModEq.of_mul_left 2 n 1 2
440+
simpa [ModEq] using @ModEq.of_mul_left 2 n 1 2
444441

445442
theorem odd_of_mod_four_eq_three {n : ℕ} : n % 4 = 3 → n % 2 = 1 := by
446-
simpa [ModEq, show 2 * 2 = 4 by norm_num, show 3 % 4 = 3 by norm_num] using
447-
@ModEq.of_mul_left 2 n 3 2
443+
simpa [ModEq] using @ModEq.of_mul_left 2 n 3 2
448444

449445
/-- A natural number is odd iff it has residue `1` or `3` mod `4`-/
450446
theorem odd_mod_four_iff {n : ℕ} : n % 2 = 1 ↔ n % 4 = 1 ∨ n % 4 = 3 :=
451447
have help : ∀ m : ℕ, m < 4 → m % 2 = 1 → m = 1 ∨ m = 3 := by decide
452448
fun hn =>
453-
help (n % 4) (mod_lt n (by norm_num)) <| (mod_mod_of_dvd n (by decide : 24)).trans hn,
449+
help (n % 4) (mod_lt n (by omega)) <| (mod_mod_of_dvd n (by decide : 24)).trans hn,
454450
fun h => Or.elim h odd_of_mod_four_eq_one odd_of_mod_four_eq_three⟩
455451

456452
lemma mod_eq_of_modEq {a b n} (h : a ≡ b [MOD n]) (hb : b < n) : a % n = b :=

Mathlib/Data/ZMod/Defs.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Authors: Eric Rodriguez
55
-/
66
import Mathlib.Algebra.Group.Fin.Basic
77
import Mathlib.Algebra.NeZero
8+
import Mathlib.Algebra.Ring.Int
89
import Mathlib.Data.Nat.ModEq
910
import Mathlib.Data.Fintype.Card
1011

Mathlib/Logic/Godel/GodelBetaFunction.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ private lemma pairwise_coprime_coprimes (a : Fin m → ℕ) : Pairwise (Coprime
7676
have hja : j < supOfSeq a := lt_of_lt_of_le j.prop (le_step (le_max_left _ _))
7777
exact coprime_mul_succ
7878
(Nat.succ_le_succ <| le_of_lt ltij)
79-
(Nat.dvd_factorial
80-
(by simp [Nat.succ_sub_succ, ltij])
79+
(Nat.dvd_factorial (by omega)
8180
(by simpa only [Nat.succ_sub_succ] using le_of_lt (lt_of_le_of_lt (sub_le j i) hja)))
8281

8382
/-- Gödel's Beta Function. This is similar to `(Encodable.decodeList).get i`, but it is easier to

Mathlib/Order/Filter/AtTopBot/ModEq.lean

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ Copyright (c) 2021 Yury Kudryashov. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Yury Kudryashov
55
-/
6-
import Mathlib.Algebra.Order.Ring.Abs
6+
import Mathlib.Algebra.Order.Ring.Basic
7+
import Mathlib.Algebra.Order.Ring.Nat
8+
import Mathlib.Algebra.Ring.Divisibility.Basic
9+
import Mathlib.Algebra.Ring.Int
710
import Mathlib.Data.Nat.ModEq
811
import Mathlib.Order.Filter.AtTopBot.Monoid
912

0 commit comments

Comments
 (0)