Skip to content

Commit 00c938f

Browse files
committed
feat: generalize Mathlib.Algebra.Group+Ring+Field (#23143)
This is one of a series of PRs that generalizes type classes across Mathlib. These are generated using a new linter that tries to re-elaborate theorem definitions with more general type classes to see if it succeeds. It will accept the generalization if deleting the entire type class causes the theorem to fail to compile, and the old type class can not simply be re-synthesized with the new declaration. Otherwise, the generalization is rejected as the type class is not being generalized, but can simply be replaced by implicit type class synthesis or an implicit type class in a variable block being pulled in. The linter currently output debug statements indicating source file positions where type classes should be generalized, and a script then makes those edits. This file contains a subset of those generalizations. The linter and the script performing re-writes is available in commit 5e2b704. Also see discussion on Zulip here: https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/Elab.20to.20generalize.20type.20classes.20for.20theorems/near/498862988 https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Elab.20to.20generalize.20type.20classes.20for.20theorems/near/501288855
1 parent b4e2ffb commit 00c938f

29 files changed

+57
-54
lines changed

Mathlib/Algebra/Field/NegOnePow.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Mathlib.Tactic.NormNum
1111

1212
namespace Int
1313

14-
lemma cast_negOnePow (K : Type*) (n : ℤ) [Field K] : n.negOnePow = (-1 : K) ^ n := by
14+
lemma cast_negOnePow (K : Type*) (n : ℤ) [DivisionRing K] : n.negOnePow = (-1 : K) ^ n := by
1515
rcases even_or_odd' n with ⟨k, rfl | rfl⟩
1616
· simp [zpow_mul, zpow_ofNat]
1717
· rw [zpow_add_one₀ (by norm_num), zpow_mul, zpow_ofNat]

Mathlib/Algebra/Field/Periodic.lean

+5-5
Original file line numberDiff line numberDiff line change
@@ -111,30 +111,30 @@ theorem Periodic.image_uIcc [LinearOrderedAddCommGroup α] [Archimedean α] (h :
111111

112112
/-! ### Antiperiodicity -/
113113

114-
theorem Antiperiodic.add_nat_mul_eq [Semiring α] [Ring β] (h : Antiperiodic f c) (n : ℕ) :
114+
theorem Antiperiodic.add_nat_mul_eq [NonAssocSemiring α] [Ring β] (h : Antiperiodic f c) (n : ℕ) :
115115
f (x + n * c) = (-1) ^ n * f x := by
116116
simpa only [nsmul_eq_mul, zsmul_eq_mul, Int.cast_pow, Int.cast_neg,
117117
Int.cast_one] using h.add_nsmul_eq n
118118

119-
theorem Antiperiodic.sub_nat_mul_eq [Ring α] [Ring β] (h : Antiperiodic f c) (n : ℕ) :
119+
theorem Antiperiodic.sub_nat_mul_eq [NonAssocRing α] [Ring β] (h : Antiperiodic f c) (n : ℕ) :
120120
f (x - n * c) = (-1) ^ n * f x := by
121121
simpa only [nsmul_eq_mul, zsmul_eq_mul, Int.cast_pow, Int.cast_neg,
122122
Int.cast_one] using h.sub_nsmul_eq n
123123

124-
theorem Antiperiodic.nat_mul_sub_eq [Ring α] [Ring β] (h : Antiperiodic f c) (n : ℕ) :
124+
theorem Antiperiodic.nat_mul_sub_eq [NonAssocRing α] [Ring β] (h : Antiperiodic f c) (n : ℕ) :
125125
f (n * c - x) = (-1) ^ n * f (-x) := by
126126
simpa only [nsmul_eq_mul, zsmul_eq_mul, Int.cast_pow, Int.cast_neg,
127127
Int.cast_one] using h.nsmul_sub_eq n
128128

129-
theorem Antiperiodic.const_smul₀ [AddCommMonoid α] [Neg β] [DivisionSemiring γ] [Module γ α]
129+
theorem Antiperiodic.const_smul₀ [AddMonoid α] [Neg β] [GroupWithZero γ] [DistribMulAction γ α]
130130
(h : Antiperiodic f c) {a : γ} (ha : a ≠ 0) : Antiperiodic (fun x => f (a • x)) (a⁻¹ • c) :=
131131
fun x => by simpa only [smul_add, smul_inv_smul₀ ha] using h (a • x)
132132

133133
theorem Antiperiodic.const_mul [DivisionSemiring α] [Neg β] (h : Antiperiodic f c) {a : α}
134134
(ha : a ≠ 0) : Antiperiodic (fun x => f (a * x)) (a⁻¹ * c) :=
135135
h.const_smul₀ ha
136136

137-
theorem Antiperiodic.const_inv_smul₀ [AddCommMonoid α] [Neg β] [DivisionSemiring γ] [Module γ α]
137+
theorem Antiperiodic.const_inv_smul₀ [AddMonoid α] [Neg β] [GroupWithZero γ] [DistribMulAction γ α]
138138
(h : Antiperiodic f c) {a : γ} (ha : a ≠ 0) : Antiperiodic (fun x => f (a⁻¹ • x)) (a • c) := by
139139
simpa only [inv_inv] using h.const_smul₀ (inv_ne_zero ha)
140140

Mathlib/Algebra/Group/Action/Pointwise/Finset.lean

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ theorem pairwiseDisjoint_smul_iff {s : Set α} {t : Finset α} :
146146
end IsLeftCancelMul
147147

148148
@[to_additive]
149-
theorem image_smul_distrib [DecidableEq α] [DecidableEq β] [Monoid α] [Monoid β] [FunLike F α β]
150-
[MonoidHomClass F α β] (f : F) (a : α) (s : Finset α) : (a • s).image f = f a • s.image f :=
149+
theorem image_smul_distrib [DecidableEq α] [DecidableEq β] [Mul α] [Mul β] [FunLike F α β]
150+
[MulHomClass F α β] (f : F) (a : α) (s : Finset α) : (a • s).image f = f a • s.image f :=
151151
image_comm <| map_mul _ _
152152

153153
section Group

Mathlib/Algebra/Group/Action/Pointwise/Set/Basic.lean

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@ open scoped RightActions
9292
end Mul
9393

9494
@[to_additive]
95-
lemma image_smul_distrib [MulOneClass α] [MulOneClass β] [FunLike F α β] [MonoidHomClass F α β]
95+
lemma image_smul_distrib [Mul α] [Mul β] [FunLike F α β] [MulHomClass F α β]
9696
(f : F) (a : α) (s : Set α) :
9797
f '' (a • s) = f a • f '' s :=
9898
image_comm <| map_mul _ _
9999

100100
open scoped RightActions in
101101
@[to_additive]
102-
lemma image_op_smul_distrib [MulOneClass α] [MulOneClass β] [FunLike F α β] [MonoidHomClass F α β]
102+
lemma image_op_smul_distrib [Mul α] [Mul β] [FunLike F α β] [MulHomClass F α β]
103103
(f : F) (a : α) (s : Set α) : f '' (s <• a) = f '' s <• f a := image_comm fun _ ↦ map_mul ..
104104

105105
section Semigroup

Mathlib/Algebra/Group/Defs.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ def nsmulRec' {M : Type*} [Zero M] [Add M] : ℕ → M → M
457457
attribute [to_additive existing] npowRec'
458458

459459
@[to_additive]
460-
theorem npowRec'_succ {M : Type*} [Semigroup M] [One M] {k : ℕ} (_ : k ≠ 0) (m : M) :
460+
theorem npowRec'_succ {M : Type*} [Mul M] [One M] {k : ℕ} (_ : k ≠ 0) (m : M) :
461461
npowRec' (k + 1) m = npowRec' k m * m :=
462462
match k with
463463
| _ + 1 => rfl

Mathlib/Algebra/Group/Embedding.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def mulRightEmbedding [Mul G] [IsRightCancelMul G] (g : G) : G ↪ G where
3535
inj' := mul_left_injective g
3636

3737
@[to_additive]
38-
theorem mulLeftEmbedding_eq_mulRightEmbedding [CommSemigroup G] [IsCancelMul G] (g : G) :
38+
theorem mulLeftEmbedding_eq_mulRightEmbedding [CommMagma G] [IsCancelMul G] (g : G) :
3939
mulLeftEmbedding g = mulRightEmbedding g := by
4040
ext
4141
exact mul_comm _ _

Mathlib/Algebra/Group/ForwardDiff.lean

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ lemma fwdDiff_smul {R : Type} [Ring R] [Module R G] (f : M → R) (g : M → G)
5757

5858
-- Note `fwdDiff_const_smul` is more general than `fwdDiff_smul` since it allows `R` to be a
5959
-- semiring, rather than a ring; in particular `R = ℕ` is allowed.
60-
@[simp] lemma fwdDiff_const_smul {R : Type*} [Semiring R] [Module R G] (r : R) (f : M → G) :
60+
@[simp] lemma fwdDiff_const_smul {R : Type*} [Monoid R] [DistribMulAction R G] (r : R) (f : M → G) :
6161
Δ_[h] (r • f) = r • Δ_[h] f :=
6262
funext fun _ ↦ (smul_sub ..).symm
6363

@@ -118,7 +118,7 @@ open fwdDiff_aux
118118
Δ_[h]^[n] (f + g) = Δ_[h]^[n] f + Δ_[h]^[n] g := by
119119
simpa only [coe_fwdDiffₗ_pow] using map_add (fwdDiffₗ M G h ^ n) f g
120120

121-
@[simp] lemma fwdDiff_iter_const_smul {R : Type*} [Semiring R] [Module R G]
121+
@[simp] lemma fwdDiff_iter_const_smul {R : Type*} [Monoid R] [DistribMulAction R G]
122122
(r : R) (f : M → G) (n : ℕ) : Δ_[h]^[n] (r • f) = r • Δ_[h]^[n] f := by
123123
induction' n with n IH generalizing f
124124
· simp only [iterate_zero, id_eq]

Mathlib/Algebra/Group/Hom/Defs.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ theorem map_div' [DivInvMonoid G] [DivInvMonoid H] [MulHomClass F G H]
414414
rw [div_eq_mul_inv, div_eq_mul_inv, map_mul, hf]
415415

416416
@[to_additive]
417-
lemma map_comp_div' [DivInvMonoid G] [DivInvMonoid H] [MonoidHomClass F G H] (f : F)
417+
lemma map_comp_div' [DivInvMonoid G] [DivInvMonoid H] [MulHomClass F G H] (f : F)
418418
(hf : ∀ a, f a⁻¹ = (f a)⁻¹) (g h : ι → G) : f ∘ (g / h) = f ∘ g / f ∘ h := by
419419
ext; simp [map_div' f hf]
420420

Mathlib/Algebra/Group/Hom/Instances.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ theorem AddMonoid.End.zero_apply [AddCommMonoid M] (m : M) : (0 : AddMonoid.End
7878
rfl
7979

8080
-- Note: `@[simp]` omitted because `(1 : AddMonoid.End M) = id` by `AddMonoid.End.coe_one`
81-
theorem AddMonoid.End.one_apply [AddCommMonoid M] (m : M) : (1 : AddMonoid.End M) m = m :=
81+
theorem AddMonoid.End.one_apply [AddZeroClass M] (m : M) : (1 : AddMonoid.End M) m = m :=
8282
rfl
8383

8484
instance AddMonoid.End.instAddCommGroup [AddCommGroup M] : AddCommGroup (AddMonoid.End M) :=

Mathlib/Algebra/Group/Nat/Hom.lean

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ section AddMonoidHomClass
2323

2424
variable {A B F : Type*} [FunLike F ℕ A]
2525

26-
lemma ext_nat' [AddMonoid A] [AddMonoidHomClass F ℕ A] (f g : F) (h : f 1 = g 1) : f = g :=
26+
lemma ext_nat' [AddZeroClass A] [AddMonoidHomClass F ℕ A] (f g : F) (h : f 1 = g 1) : f = g :=
2727
DFunLike.ext f g <| by
2828
intro n
2929
induction n with
@@ -32,7 +32,7 @@ lemma ext_nat' [AddMonoid A] [AddMonoidHomClass F ℕ A] (f g : F) (h : f 1 = g
3232
simp [h, ihn]
3333

3434
@[ext]
35-
lemma AddMonoidHom.ext_nat [AddMonoid A] {f g : ℕ →+ A} : f 1 = g 1 → f = g :=
35+
lemma AddMonoidHom.ext_nat [AddZeroClass A] {f g : ℕ →+ A} : f 1 = g 1 → f = g :=
3636
ext_nat' f g
3737

3838
end AddMonoidHomClass

Mathlib/Algebra/Group/Pointwise/Set/Basic.lean

+2-2
Original file line numberDiff line numberDiff line change
@@ -1257,13 +1257,13 @@ lemma MapsTo.mul [Mul β] {A : Set α} {B₁ B₂ : Set β} {f₁ f₂ : α →
12571257
fun _ h => mul_mem_mul (h₁ h) (h₂ h)
12581258

12591259
@[to_additive]
1260-
lemma MapsTo.inv [DivisionCommMonoid β] {A : Set α} {B : Set β} {f : α → β} (h : MapsTo f A B) :
1260+
lemma MapsTo.inv [InvolutiveInv β] {A : Set α} {B : Set β} {f : α → β} (h : MapsTo f A B) :
12611261
MapsTo (f⁻¹) A (B⁻¹) :=
12621262
fun _ ha => inv_mem_inv.2 (h ha)
12631263

12641264

12651265
@[to_additive]
1266-
lemma MapsTo.div [DivisionCommMonoid β] {A : Set α} {B₁ B₂ : Set β} {f₁ f₂ : α → β}
1266+
lemma MapsTo.div [Div β] {A : Set α} {B₁ B₂ : Set β} {f₁ f₂ : α → β}
12671267
(h₁ : MapsTo f₁ A B₁) (h₂ : MapsTo f₂ A B₂) : MapsTo (f₁ / f₂) A (B₁ / B₂) :=
12681268
fun _ ha => div_mem_div (h₁ ha) (h₂ ha)
12691269

Mathlib/Algebra/Group/Pointwise/Set/BigOperators.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ theorem list_prod_subset_list_prod (t : List ι) (f₁ f₂ : ι → Set α) (hf
104104
(ih fun i hi ↦ hf i <| List.mem_cons_of_mem _ hi)
105105

106106
@[to_additive]
107-
theorem list_prod_singleton {M : Type*} [CommMonoid M] (s : List M) :
107+
theorem list_prod_singleton {M : Type*} [Monoid M] (s : List M) :
108108
(s.map fun i ↦ ({i} : Set M)).prod = {s.prod} :=
109109
(map_list_prod (singletonMonoidHom : M →* Set M) _).symm
110110

Mathlib/Algebra/Group/Subgroup/Ker.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ theorem coe_toAdditive_ker (f : G →* G') :
320320
(MonoidHom.toAdditive f).ker = Subgroup.toAddSubgroup f.ker := rfl
321321

322322
@[simp]
323-
theorem coe_toMultiplicative_ker {A A' : Type*} [AddGroup A] [AddGroup A'] (f : A →+ A') :
323+
theorem coe_toMultiplicative_ker {A A' : Type*} [AddGroup A] [AddZeroClass A'] (f : A →+ A') :
324324
(AddMonoidHom.toMultiplicative f).ker = AddSubgroup.toSubgroup f.ker := rfl
325325

326326
end Ker

Mathlib/Algebra/Group/Subgroup/Order.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,6 @@ lemma MulEquiv.strictMono_subsemigroupCongr {G : Type*} [OrderedCommMonoid G] {S
123123

124124
@[to_additive]
125125
lemma MulEquiv.strictMono_symm {G G' : Type*} [LinearOrderedCommMonoid G]
126-
[LinearOrderedCommMonoid G'] {e : G ≃* G'} (he : StrictMono e) : StrictMono e.symm := by
126+
[OrderedCommMonoid G'] {e : G ≃* G'} (he : StrictMono e) : StrictMono e.symm := by
127127
intro
128128
simp [← he.lt_iff_lt]

Mathlib/Algebra/Group/Submonoid/Operations.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ theorem mem_mrange {f : F} {y : N} : y ∈ mrange f ↔ ∃ x, f x = y :=
630630
Iff.rfl
631631

632632
@[to_additive]
633-
lemma mrange_comp {O : Type*} [Monoid O] (f : N →* O) (g : M →* N) :
633+
lemma mrange_comp {O : Type*} [MulOneClass O] (f : N →* O) (g : M →* N) :
634634
mrange (f.comp g) = (mrange g).map f := SetLike.coe_injective <| Set.range_comp f _
635635

636636
@[to_additive]

Mathlib/Algebra/GroupWithZero/Hom.lean

+12
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,18 @@ protected lemma map_zero (f : α →*₀ β) : f 0 = 0 := f.map_zero'
151151

152152
protected lemma map_mul (f : α →*₀ β) (a b : α) : f (a * b) = f a * f b := f.map_mul' a b
153153

154+
@[simp]
155+
theorem map_ite_zero_one {F : Type*} [FunLike F α β] [MonoidWithZeroHomClass F α β] (f : F)
156+
(p : Prop) [Decidable p] :
157+
f (ite p 0 1) = ite p 0 1 := by
158+
split_ifs with h <;> simp [h]
159+
160+
@[simp]
161+
theorem map_ite_one_zero {F : Type*} [FunLike F α β] [MonoidWithZeroHomClass F α β] (f : F)
162+
(p : Prop) [Decidable p] :
163+
f (ite p 1 0) = ite p 1 0 := by
164+
split_ifs with h <;> simp [h]
165+
154166
/-- The identity map from a `MonoidWithZero` to itself. -/
155167
@[simps]
156168
def id (α : Type*) [MulZeroOneClass α] : α →*₀ α where

Mathlib/Algebra/Ring/Basic.lean

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ section NoZeroDivisors
124124

125125
variable (α)
126126

127-
lemma IsLeftCancelMulZero.to_noZeroDivisors [NonUnitalNonAssocSemiring α]
127+
lemma IsLeftCancelMulZero.to_noZeroDivisors [MulZeroClass α]
128128
[IsLeftCancelMulZero α] : NoZeroDivisors α where
129129
eq_zero_or_eq_zero_of_mul_eq_zero {x _} h :=
130130
or_iff_not_imp_left.mpr fun ne ↦ mul_left_cancel₀ ne ((mul_zero x).symm ▸ h)
131131

132-
lemma IsRightCancelMulZero.to_noZeroDivisors [NonUnitalNonAssocSemiring α]
132+
lemma IsRightCancelMulZero.to_noZeroDivisors [MulZeroClass α]
133133
[IsRightCancelMulZero α] : NoZeroDivisors α where
134134
eq_zero_or_eq_zero_of_mul_eq_zero {_ y} h :=
135135
or_iff_not_imp_right.mpr fun ne ↦ mul_right_cancel₀ ne ((zero_mul y).symm ▸ h)

Mathlib/Algebra/Ring/Commute.lean

+3-2
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,14 @@ lemma sq_ne_one_iff : a ^ 2 ≠ 1 ↔ a ≠ 1 ∧ a ≠ -1 := sq_eq_one_iff.not.
163163
end Ring
164164

165165
/-- Representation of a difference of two squares in a commutative ring as a product. -/
166-
theorem mul_self_sub_mul_self [CommRing R] (a b : R) : a * a - b * b = (a + b) * (a - b) :=
166+
theorem mul_self_sub_mul_self [NonUnitalNonAssocCommRing R] (a b : R) :
167+
a * a - b * b = (a + b) * (a - b) :=
167168
(Commute.all a b).mul_self_sub_mul_self_eq
168169

169170
theorem mul_self_sub_one [NonAssocRing R] (a : R) : a * a - 1 = (a + 1) * (a - 1) := by
170171
rw [← (Commute.one_right a).mul_self_sub_mul_self_eq, mul_one]
171172

172-
theorem mul_self_eq_mul_self_iff [CommRing R] [NoZeroDivisors R] {a b : R} :
173+
theorem mul_self_eq_mul_self_iff [NonUnitalNonAssocCommRing R] [NoZeroDivisors R] {a b : R} :
173174
a * a = b * b ↔ a = b ∨ a = -b :=
174175
(Commute.all a b).mul_self_eq_mul_self_iff
175176

Mathlib/Algebra/Ring/Equiv.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ theorem coe_monoidHom_trans [NonAssocSemiring S'] (e₁ : R ≃+* S) (e₂ : S
590590
rfl
591591

592592
@[simp]
593-
theorem coe_addMonoidHom_trans [NonAssocSemiring S'] (e₁ : R ≃+* S) (e₂ : S ≃+* S') :
593+
theorem coe_addMonoidHom_trans [NonUnitalNonAssocSemiring S'] (e₁ : R ≃+* S) (e₂ : S ≃+* S') :
594594
(e₁.trans e₂ : R →+ S') = (e₂ : S →+ S').comp ↑e₁ :=
595595
rfl
596596

Mathlib/Algebra/Ring/Hom/Defs.lean

-12
Original file line numberDiff line numberDiff line change
@@ -463,18 +463,6 @@ protected theorem map_add (f : α →+* β) : ∀ a b, f (a + b) = f a + f b :=
463463
protected theorem map_mul (f : α →+* β) : ∀ a b, f (a * b) = f a * f b :=
464464
map_mul f
465465

466-
@[simp]
467-
theorem map_ite_zero_one {F : Type*} [FunLike F α β] [RingHomClass F α β] (f : F)
468-
(p : Prop) [Decidable p] :
469-
f (ite p 0 1) = ite p 0 1 := by
470-
split_ifs with h <;> simp [h]
471-
472-
@[simp]
473-
theorem map_ite_one_zero {F : Type*} [FunLike F α β] [RingHomClass F α β] (f : F)
474-
(p : Prop) [Decidable p] :
475-
f (ite p 1 0) = ite p 1 0 := by
476-
split_ifs with h <;> simp [h]
477-
478466
/-- `f : α →+* β` has a trivial codomain iff `f 1 = 0`. -/
479467
theorem codomain_trivial_iff_map_one_eq_zero : (0 : β) = 1 ↔ f 1 = 0 := by rw [map_one, eq_comm]
480468

Mathlib/Algebra/Ring/Int/Defs.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ lemma cast_mul {α : Type*} [NonAssocRing α] : ∀ m n, ((m * n : ℤ) : α) =
5757
| succ m ih => simp_all [add_mul]
5858

5959
/-- Note this holds in marginally more generality than `Int.cast_mul` -/
60-
lemma cast_mul_eq_zsmul_cast {α : Type*} [AddCommGroupWithOne α] :
60+
lemma cast_mul_eq_zsmul_cast {α : Type*} [AddGroupWithOne α] :
6161
∀ m n : ℤ, ↑(m * n) = m • (n : α) :=
6262
fun m ↦ Int.induction_on m (by simp) (fun _ ih ↦ by simp [add_mul, add_zsmul, ih]) fun _ ih ↦ by
6363
simp only [sub_mul, one_mul, cast_sub, ih, sub_zsmul, one_zsmul, ← sub_eq_add_neg, forall_const]

Mathlib/Algebra/Ring/Invertible.lean

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ theorem one_sub_invOf_two [Ring α] [Invertible (2 : α)] : 1 - (⅟ 2 : α) =
3232
theorem invOf_two_add_invOf_two [NonAssocSemiring α] [Invertible (2 : α)] :
3333
(⅟ 2 : α) + (⅟ 2 : α) = 1 := by rw [← two_mul, mul_invOf_self]
3434

35-
theorem pos_of_invertible_cast [Semiring α] [Nontrivial α] (n : ℕ) [Invertible (n : α)] : 0 < n :=
35+
theorem pos_of_invertible_cast [NonAssocSemiring α] [Nontrivial α] (n : ℕ) [Invertible (n : α)] :
36+
0 < n :=
3637
Nat.zero_lt_of_ne_zero fun h => Invertible.ne_zero (n : α) (h ▸ Nat.cast_zero)
3738

3839
theorem invOf_add_invOf [Semiring α] (a b : α) [Invertible a] [Invertible b] :

Mathlib/Algebra/Ring/Parity.lean

+2-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ lemma Even.trans_dvd (ha : Even a) (hab : a ∣ b) : Even b :=
7070

7171
lemma Dvd.dvd.even (hab : a ∣ b) (ha : Even a) : Even b := ha.trans_dvd hab
7272

73-
@[simp] lemma range_two_mul (α) [Semiring α] : Set.range (fun x : α ↦ 2 * x) = {a | Even a} := by
73+
@[simp] lemma range_two_mul (α) [NonAssocSemiring α] :
74+
Set.range (fun x : α ↦ 2 * x) = {a | Even a} := by
7475
ext x
7576
simp [eq_comm, two_mul, Even]
7677

Mathlib/Algebra/Ring/Prod.lean

+2-2
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,8 @@ def zeroRingProd : R ≃+* S × R where
330330
end RingEquiv
331331

332332
/-- The product of two nontrivial rings is not a domain -/
333-
theorem false_of_nontrivial_of_product_domain (R S : Type*) [Ring R] [Ring S] [IsDomain (R × S)]
334-
[Nontrivial R] [Nontrivial S] : False := by
333+
theorem false_of_nontrivial_of_product_domain (R S : Type*) [Semiring R] [Semiring S]
334+
[IsDomain (R × S)] [Nontrivial R] [Nontrivial S] : False := by
335335
have :=
336336
NoZeroDivisors.eq_zero_or_eq_zero_of_mul_eq_zero (show ((0 : R), (1 : S)) * (1, 0) = 0 by simp)
337337
rw [Prod.mk_eq_zero, Prod.mk_eq_zero] at this

Mathlib/Algebra/Ring/Subsemiring/Defs.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ instance (priority := 75) toSemiring {R} [Semiring R] [SetLike S R] [Subsemiring
105105
(fun _ _ => rfl) (fun _ _ => rfl) fun _ => rfl
106106

107107
@[simp, norm_cast]
108-
theorem coe_pow {R} [Semiring R] [SetLike S R] [SubsemiringClass S R] (x : s) (n : ℕ) :
108+
theorem coe_pow {R} [Monoid R] [SetLike S R] [SubmonoidClass S R] (x : s) (n : ℕ) :
109109
((x ^ n : s) : R) = (x : R) ^ n := by
110110
induction n with
111111
| zero => simp

Mathlib/Algebra/Ring/Units.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ theorem IsUnit.sub_iff [Ring α] {x y : α} : IsUnit (x - y) ↔ IsUnit (y - x)
106106
namespace Units
107107

108108
@[field_simps]
109-
theorem divp_add_divp [CommRing α] (a b : α) (u₁ u₂ : αˣ) :
109+
theorem divp_add_divp [CommSemiring α] (a b : α) (u₁ u₂ : αˣ) :
110110
a /ₚ u₁ + b /ₚ u₂ = (a * u₂ + u₁ * b) /ₚ (u₁ * u₂) := by
111111
simp only [divp, add_mul, mul_inv_rev, val_mul]
112112
rw [mul_comm (↑u₁ * b), mul_comm b]

Mathlib/RingTheory/Kaehler/JacobiZariski.lean

+3-3
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ lemma CotangentSpace.compEquiv_symm_inr :
138138
Basis.repr_self, Basis.prod_repr_inl, map_zero, Finsupp.coe_zero,
139139
Pi.zero_apply, ne_eq, not_false_eq_true, Pi.single_eq_of_ne, Pi.single_apply,
140140
Finsupp.single_apply, ite_smul, one_smul, zero_smul, Sum.inr.injEq,
141-
RingHom.map_ite_one_zero, reduceCtorEq, ↓reduceIte]
141+
MonoidWithZeroHom.map_ite_one_zero, reduceCtorEq, ↓reduceIte]
142142

143143
lemma CotangentSpace.compEquiv_symm_zero (x) :
144144
(compEquiv Q P).symm (0, x) =
@@ -158,9 +158,9 @@ lemma CotangentSpace.fst_compEquiv :
158158
obtain (i | i) := i <;>
159159
simp only [comp_vars, Basis.repr_symm_apply, Finsupp.linearCombination_single, Basis.prod_apply,
160160
LinearMap.coe_inl, LinearMap.coe_inr, Sum.elim_inl, Function.comp_apply, one_smul,
161-
Basis.repr_self, Finsupp.single_apply, pderiv_X, Pi.single_apply, RingHom.map_ite_one_zero,
161+
Basis.repr_self, Finsupp.single_apply, pderiv_X, Pi.single_apply,
162162
Sum.elim_inr, Function.comp_apply, Basis.baseChange_apply, one_smul,
163-
map_zero, Finsupp.coe_zero, Pi.zero_apply, derivation_C]
163+
MonoidWithZeroHom.map_ite_one_zero, map_zero, Finsupp.coe_zero, Pi.zero_apply, derivation_C]
164164

165165
lemma CotangentSpace.fst_compEquiv_apply (x) :
166166
(compEquiv Q P x).1 = Extension.CotangentSpace.map (Q.ofComp P).toExtensionHom x :=

Mathlib/RingTheory/MvPowerSeries/Basic.lean

+2-2
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,8 @@ def map : MvPowerSeries σ R →+* MvPowerSeries σ S where
501501
classical
502502
rw [coeff_one, coeff_one]
503503
split_ifs with h
504-
· simp only [RingHom.map_ite_one_zero, ite_true, map_one, h]
505-
· simp only [RingHom.map_ite_one_zero, ite_false, map_zero, h]
504+
· simp only [ite_true, map_one, h]
505+
· simp only [ite_false, map_zero, h]
506506
map_add' φ ψ :=
507507
ext fun n => show f ((coeff R n) (φ + ψ)) = f ((coeff R n) φ) + f ((coeff R n) ψ) by simp
508508
map_mul' φ ψ :=

Mathlib/RingTheory/Trace/Basic.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ lemma traceForm_dualBasis_powerBasis_eq [FiniteDimensional K L] [Algebra.IsSepar
490490
map_pow, RingHom.coe_coe, AlgHom.coe_coe, finset_sum_coeff, coeff_smul, coeff_map, smul_eq_mul,
491491
coeff_X_pow, ← Fin.ext_iff, @eq_comm _ i] at this
492492
rw [PowerBasis.coe_basis]
493-
simp only [RingHom.map_ite_one_zero, traceForm_apply]
493+
simp only [MonoidWithZeroHom.map_ite_one_zero, traceForm_apply]
494494
rw [← this, trace_eq_sum_embeddings (E := AlgebraicClosure K)]
495495
apply Finset.sum_congr rfl
496496
intro σ _

0 commit comments

Comments
 (0)