Skip to content

Commit 79da87b

Browse files
committed
fix: remove references to non-heterogenous operators in theorem statements (#8086)
Some of these are likely porting errors. Statements should always be about the heterogenous versions because these are the ones with notation. For places where we are abusing defeq, this debuts the trick of using `(by exact a : B) = (by exact a1) + (by exact b2)` to ensure the `=` and `+` are typed as `B` instead of `A`.
1 parent 59a1489 commit 79da87b

File tree

8 files changed

+48
-34
lines changed

8 files changed

+48
-34
lines changed

Mathlib/Algebra/Category/GroupCat/Colimits.lean

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,18 @@ theorem quot_zero : Quot.mk Setoid.r zero = (0 : ColimitType.{w} F) :=
128128
#align AddCommGroup.colimits.quot_zero AddCommGroupCat.Colimits.quot_zero
129129

130130
@[simp]
131-
theorem quot_neg (x) : Quot.mk Setoid.r (neg x) =
131+
theorem quot_neg (x) :
132132
-- Porting note : force Lean to treat `ColimitType F` no as `Quot _`
133-
Neg.neg (α := ColimitType.{w} F) (Quot.mk Setoid.r x : ColimitType.{w} F) :=
133+
(by exact Quot.mk Setoid.r (neg x) : ColimitType.{w} F) =
134+
-(by exact Quot.mk Setoid.r x) :=
134135
rfl
135136
#align AddCommGroup.colimits.quot_neg AddCommGroupCat.Colimits.quot_neg
136137

137138
@[simp]
138139
theorem quot_add (x y) :
139-
Quot.mk Setoid.r (add x y) =
140-
-- Porting note : force Lean to treat `ColimitType F` no as `Quot _`
141-
Add.add (α := ColimitType.{w} F) (Quot.mk Setoid.r x) (Quot.mk Setoid.r y) :=
140+
(by exact Quot.mk Setoid.r (add x y) : ColimitType.{w} F) =
141+
-- Porting note : force Lean to treat `ColimitType F` no as `Quot _`
142+
(by exact Quot.mk Setoid.r x) + (by exact Quot.mk Setoid.r y) :=
142143
rfl
143144
#align AddCommGroup.colimits.quot_add AddCommGroupCat.Colimits.quot_add
144145

@@ -220,7 +221,7 @@ def descMorphism (s : Cocone F) : colimit.{w} F ⟶ s.pt where
220221
toFun := descFun F s
221222
map_zero' := rfl
222223
-- Porting note : in `mathlib3`, nothing needs to be done after `induction`
223-
map_add' x y := Quot.induction_on₂ x y fun _ _ => by dsimp [(· + ·)]; rw [←quot_add F]; rfl
224+
map_add' x y := Quot.induction_on₂ x y fun _ _ => by dsimp; rw [←quot_add F]; rfl
224225
#align AddCommGroup.colimits.desc_morphism AddCommGroupCat.Colimits.descMorphism
225226

226227
/-- Evidence that the proposed colimit is the colimit. -/

Mathlib/Algebra/Category/Ring/Colimits.lean

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,26 +191,26 @@ theorem quot_one : Quot.mk Setoid.r one = (1 : ColimitType F) :=
191191
@[simp]
192192
theorem quot_neg (x : Prequotient F) :
193193
-- Porting note : Lean can't see `Quot.mk Setoid.r x` is a `ColimitType F` even with type
194-
-- annotation so use `Neg.neg (α := ColimitType F)` to tell Lean negation happens inside
195-
-- `ColimitType F`.
196-
(Quot.mk Setoid.r (neg x) : ColimitType F) =
197-
Neg.neg (α := ColimitType F) (Quot.mk Setoid.r x) :=
194+
-- annotation unless we use `by exact` to change the elaboration order.
195+
(by exact Quot.mk Setoid.r (neg x) : ColimitType F) = -(by exact Quot.mk Setoid.r x) :=
198196
rfl
199197
#align CommRing.colimits.quot_neg CommRingCat.Colimits.quot_neg
200198

201199
-- Porting note : Lean can't see `Quot.mk Setoid.r x` is a `ColimitType F` even with type annotation
202-
-- so use `Add.add (α := ColimitType F)` to tell Lean addition happens inside `ColimitType F`.
200+
-- unless we use `by exact` to change the elaboration order.
203201
@[simp]
204202
theorem quot_add (x y) :
205-
Quot.mk Setoid.r (add x y) = Add.add (α := ColimitType F) (Quot.mk _ x) (Quot.mk _ y) :=
203+
(by exact Quot.mk Setoid.r (add x y) : ColimitType F) =
204+
(by exact Quot.mk _ x) + (by exact Quot.mk _ y) :=
206205
rfl
207206
#align CommRing.colimits.quot_add CommRingCat.Colimits.quot_add
208207

209208
-- Porting note : Lean can't see `Quot.mk Setoid.r x` is a `ColimitType F` even with type annotation
210-
-- so use `Mul.mul (α := ColimitType F)` to tell Lean multiplication happens inside `ColimitType F`.
209+
-- unless we use `by exact` to change the elaboration order.
211210
@[simp]
212211
theorem quot_mul (x y) :
213-
Quot.mk Setoid.r (mul x y) = Mul.mul (α := ColimitType F) (Quot.mk _ x) (Quot.mk _ y) :=
212+
(by exact Quot.mk Setoid.r (mul x y) : ColimitType F) =
213+
(by exact Quot.mk _ x) * (by exact Quot.mk _ y) :=
214214
rfl
215215
#align CommRing.colimits.quot_mul CommRingCat.Colimits.quot_mul
216216

@@ -309,7 +309,7 @@ def descMorphism (s : Cocone F) : colimit F ⟶ s.pt where
309309
map_zero' := rfl
310310
map_add' x y := by
311311
refine Quot.induction_on₂ x y fun a b => ?_
312-
dsimp [descFun, (· + ·)]
312+
dsimp [descFun]
313313
rw [←quot_add]
314314
rfl
315315
map_mul' x y := by exact Quot.induction_on₂ x y fun a b => rfl

Mathlib/Algebra/CharP/Two.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ theorem neg_eq' : Neg.neg = (id : R → R) :=
7373
theorem sub_eq_add (x y : R) : x - y = x + y := by rw [sub_eq_add_neg, neg_eq]
7474
#align char_two.sub_eq_add CharTwo.sub_eq_add
7575

76-
theorem sub_eq_add' : Sub.sub = ((· + ·) : R → R → R) :=
76+
theorem sub_eq_add' : HSub.hSub = ((· + ·) : R → R → R) :=
7777
funext fun x => funext fun y => sub_eq_add x y
7878
#align char_two.sub_eq_add' CharTwo.sub_eq_add'
7979

Mathlib/Algebra/Free.lean

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ theorem traverse_mul (x y : FreeMagma α) :
250250

251251
@[to_additive (attr := simp)]
252252
theorem traverse_mul' :
253-
Function.comp (traverse F) ∘ @Mul.mul (FreeMagma α) _ = fun x y ↦
253+
Function.comp (traverse F) ∘ (HMul.hMul : FreeMagma α → FreeMagma α → FreeMagma α) = fun x y ↦
254254
(· * ·) <$> traverse F x <*> traverse F y := rfl
255255
#align free_magma.traverse_mul' FreeMagma.traverse_mul'
256256

@@ -664,8 +664,9 @@ theorem traverse_mul (x y : FreeSemigroup α) :
664664

665665
@[to_additive (attr := simp)]
666666
theorem traverse_mul' :
667-
Function.comp (traverse F) ∘ @Mul.mul (FreeSemigroup α) _ = fun x y ↦
668-
(· * ·) <$> traverse F x <*> traverse F y := funext fun x ↦ funext fun y ↦ traverse_mul F x y
667+
Function.comp (traverse F) ∘ (HMul.hMul : FreeSemigroup α → FreeSemigroup α → FreeSemigroup α) =
668+
fun x y ↦ (· * ·) <$> traverse F x <*> traverse F y :=
669+
funext fun x ↦ funext fun y ↦ traverse_mul F x y
669670
#align free_semigroup.traverse_mul' FreeSemigroup.traverse_mul'
670671

671672
end

Mathlib/Algebra/Group/Ext.lean

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,20 @@ in `Algebra.Group.Defs`.
1919
To get equality of `npow` etc, we define a monoid homomorphism between two monoid structures on the
2020
same type, then apply lemmas like `MonoidHom.map_div`, `MonoidHom.map_pow` etc.
2121
22+
To refer to the `*` operator of a particular instance `i`, we use
23+
`(letI := i; HMul.hMul : M → M → M)` instead of `i.mul` (which elaborates to `Mul.mul`), as the
24+
former uses `HMul.hMul` which is the canonical spelling.
25+
2226
## Tags
2327
monoid, group, extensionality
2428
-/
2529

2630
universe u
2731

2832
@[to_additive (attr := ext)]
29-
theorem Monoid.ext {M : Type u} ⦃m₁ m₂ : Monoid M⦄ (h_mul : m₁.mul = m₂.mul) : m₁ = m₂ := by
33+
theorem Monoid.ext {M : Type u} ⦃m₁ m₂ : Monoid M⦄
34+
(h_mul : (letI := m₁; HMul.hMul : M → M → M) = (letI := m₂; HMul.hMul : M → M → M)) :
35+
m₁ = m₂ := by
3036
have : m₁.toMulOneClass = m₂.toMulOneClass := MulOneClass.ext h_mul
3137
have h₁ : m₁.one = m₂.one := congr_arg (·.one) (this)
3238
let f : @MonoidHom M M m₁.toMulOneClass m₂.toMulOneClass :=
@@ -50,7 +56,8 @@ theorem CommMonoid.toMonoid_injective {M : Type u} :
5056
#align add_comm_monoid.to_add_monoid_injective AddCommMonoid.toAddMonoid_injective
5157

5258
@[to_additive (attr := ext)]
53-
theorem CommMonoid.ext {M : Type*} ⦃m₁ m₂ : CommMonoid M⦄ (h_mul : m₁.mul = m₂.mul) : m₁ = m₂ :=
59+
theorem CommMonoid.ext {M : Type*} ⦃m₁ m₂ : CommMonoid M⦄
60+
(h_mul : (letI := m₁; HMul.hMul : M → M → M) = (letI := m₂; HMul.hMul : M → M → M)) : m₁ = m₂ :=
5461
CommMonoid.toMonoid_injective <| Monoid.ext h_mul
5562
#align comm_monoid.ext CommMonoid.ext
5663
#align add_comm_monoid.ext AddCommMonoid.ext
@@ -64,7 +71,8 @@ theorem LeftCancelMonoid.toMonoid_injective {M : Type u} :
6471
#align add_left_cancel_monoid.to_add_monoid_injective AddLeftCancelMonoid.toAddMonoid_injective
6572

6673
@[to_additive (attr := ext)]
67-
theorem LeftCancelMonoid.ext {M : Type u} ⦃m₁ m₂ : LeftCancelMonoid M⦄ (h_mul : m₁.mul = m₂.mul) :
74+
theorem LeftCancelMonoid.ext {M : Type u} ⦃m₁ m₂ : LeftCancelMonoid M⦄
75+
(h_mul : (letI := m₁; HMul.hMul : M → M → M) = (letI := m₂; HMul.hMul : M → M → M)) :
6876
m₁ = m₂ :=
6977
LeftCancelMonoid.toMonoid_injective <| Monoid.ext h_mul
7078
#align left_cancel_monoid.ext LeftCancelMonoid.ext
@@ -79,7 +87,8 @@ theorem RightCancelMonoid.toMonoid_injective {M : Type u} :
7987
#align add_right_cancel_monoid.to_add_monoid_injective AddRightCancelMonoid.toAddMonoid_injective
8088

8189
@[to_additive (attr := ext)]
82-
theorem RightCancelMonoid.ext {M : Type u} ⦃m₁ m₂ : RightCancelMonoid M⦄ (h_mul : m₁.mul = m₂.mul) :
90+
theorem RightCancelMonoid.ext {M : Type u} ⦃m₁ m₂ : RightCancelMonoid M⦄
91+
(h_mul : (letI := m₁; HMul.hMul : M → M → M) = (letI := m₂; HMul.hMul : M → M → M)) :
8392
m₁ = m₂ :=
8493
RightCancelMonoid.toMonoid_injective <| Monoid.ext h_mul
8594
#align right_cancel_monoid.ext RightCancelMonoid.ext
@@ -94,7 +103,8 @@ theorem CancelMonoid.toLeftCancelMonoid_injective {M : Type u} :
94103
#align add_cancel_monoid.to_left_cancel_add_monoid_injective AddCancelMonoid.toAddLeftCancelMonoid_injective
95104

96105
@[to_additive (attr := ext)]
97-
theorem CancelMonoid.ext {M : Type*} ⦃m₁ m₂ : CancelMonoid M⦄ (h_mul : m₁.mul = m₂.mul) :
106+
theorem CancelMonoid.ext {M : Type*} ⦃m₁ m₂ : CancelMonoid M⦄
107+
(h_mul : (letI := m₁; HMul.hMul : M → M → M) = (letI := m₂; HMul.hMul : M → M → M)) :
98108
m₁ = m₂ :=
99109
CancelMonoid.toLeftCancelMonoid_injective <| LeftCancelMonoid.ext h_mul
100110
#align cancel_monoid.ext CancelMonoid.ext
@@ -111,15 +121,17 @@ theorem CancelCommMonoid.toCommMonoid_injective {M : Type u} :
111121
#align add_cancel_comm_monoid.to_add_comm_monoid_injective AddCancelCommMonoid.toAddCommMonoid_injective
112122

113123
@[to_additive (attr := ext)]
114-
theorem CancelCommMonoid.ext {M : Type*} ⦃m₁ m₂ : CancelCommMonoid M⦄ (h_mul : m₁.mul = m₂.mul) :
124+
theorem CancelCommMonoid.ext {M : Type*} ⦃m₁ m₂ : CancelCommMonoid M⦄
125+
(h_mul : (letI := m₁; HMul.hMul : M → M → M) = (letI := m₂; HMul.hMul : M → M → M)) :
115126
m₁ = m₂ :=
116127
CancelCommMonoid.toCommMonoid_injective <| CommMonoid.ext h_mul
117128
#align cancel_comm_monoid.ext CancelCommMonoid.ext
118129
#align add_cancel_comm_monoid.ext AddCancelCommMonoid.ext
119130

120131
@[to_additive (attr := ext)]
121-
theorem DivInvMonoid.ext {M : Type*} ⦃m₁ m₂ : DivInvMonoid M⦄ (h_mul : m₁.mul = m₂.mul)
122-
(h_inv : m₁.inv = m₂.inv) : m₁ = m₂ := by
132+
theorem DivInvMonoid.ext {M : Type*} ⦃m₁ m₂ : DivInvMonoid M⦄
133+
(h_mul : (letI := m₁; HMul.hMul : M → M → M) = (letI := m₂; HMul.hMul : M → M → M))
134+
(h_inv : (letI := m₁; Inv.inv : M → M) = (letI := m₂; Inv.inv : M → M)) : m₁ = m₂ := by
123135
have h_mon := Monoid.ext h_mul
124136
have h₁ : m₁.one = m₂.one := congr_arg (·.one) h_mon
125137
let f : @MonoidHom M M m₁.toMulOneClass m₂.toMulOneClass :=

Mathlib/Algebra/Order/LatticeGroup.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ theorem neg_eq_one_iff' {a : α} : a⁻ = 1 ↔ a⁻¹ ≤ 1 :=
237237
#align lattice_ordered_comm_group.neg_eq_zero_iff' LatticeOrderedGroup.neg_eq_zero_iff'
238238

239239
@[to_additive]
240-
theorem neg_eq_one_iff [CovariantClass α α Mul.mul LE.le] {a : α} : a⁻ = 11 ≤ a := by
240+
theorem neg_eq_one_iff [CovariantClass α α HMul.hMul LE.le] {a : α} : a⁻ = 11 ≤ a := by
241241
rw [le_antisymm_iff, neg_le_one_iff, inv_le_one', and_iff_left (one_le_neg _)]
242242
#align lattice_ordered_comm_group.neg_eq_one_iff LatticeOrderedGroup.neg_eq_one_iff
243243
#align lattice_ordered_comm_group.neg_eq_zero_iff LatticeOrderedGroup.neg_eq_zero_iff

Mathlib/Algebra/Order/Monoid/OrderDual.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ instance orderedCommMonoid [OrderedCommMonoid α] : OrderedCommMonoid αᵒᵈ :
8888

8989
@[to_additive OrderDual.OrderedCancelAddCommMonoid.to_contravariantClass]
9090
instance OrderedCancelCommMonoid.to_contravariantClass [OrderedCancelCommMonoid α] :
91-
ContravariantClass αᵒᵈ αᵒᵈ Mul.mul LE.le where
91+
ContravariantClass αᵒᵈ αᵒᵈ HMul.hMul LE.le where
9292
-- Porting note: We need to specify the implicit arguments here because of
9393
-- https://github.com/leanprover/lean4/issues/1892
9494
-- We should be able to remove this after nightly-2022-11-30 arrives.

Mathlib/Geometry/Manifold/MFDeriv.lean

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,11 +1616,11 @@ theorem MDifferentiable.add (hf : MDifferentiable I 𝓘(𝕜, E') f)
16161616
(hf x).add (hg x)
16171617
#align mdifferentiable.add MDifferentiable.add
16181618

1619-
-- porting note: forcing types using `@Add.add`
1619+
-- porting note: forcing types using `by exact`
16201620
theorem mfderiv_add (hf : MDifferentiableAt I 𝓘(𝕜, E') f z)
16211621
(hg : MDifferentiableAt I 𝓘(𝕜, E') g z) :
1622-
(mfderiv I 𝓘(𝕜, E') (f + g) z : TangentSpace I z →L[𝕜] E') =
1623-
@Add.add (TangentSpace I z →L[𝕜] E') _ (mfderiv I 𝓘(𝕜, E') f z) (mfderiv I 𝓘(𝕜, E') g z) :=
1622+
(by exact mfderiv I 𝓘(𝕜, E') (f + g) z : TangentSpace I z →L[𝕜] E') =
1623+
(by exact mfderiv I 𝓘(𝕜, E') f z) + (by exact mfderiv I 𝓘(𝕜, E') g z) :=
16241624
(hf.hasMFDerivAt.add hg.hasMFDerivAt).mfderiv
16251625
#align mfderiv_add mfderiv_add
16261626

@@ -1693,8 +1693,8 @@ theorem MDifferentiable.sub (hf : MDifferentiable I 𝓘(𝕜, E') f)
16931693

16941694
theorem mfderiv_sub (hf : MDifferentiableAt I 𝓘(𝕜, E') f z)
16951695
(hg : MDifferentiableAt I 𝓘(𝕜, E') g z) :
1696-
(mfderiv I 𝓘(𝕜, E') (f - g) z : TangentSpace I z →L[𝕜] E') =
1697-
@Sub.sub (TangentSpace I z →L[𝕜] E') _ (mfderiv I 𝓘(𝕜, E') f z) (mfderiv I 𝓘(𝕜, E') g z) :=
1696+
(by exact mfderiv I 𝓘(𝕜, E') (f - g) z : TangentSpace I z →L[𝕜] E') =
1697+
(by exact mfderiv I 𝓘(𝕜, E') f z) - (by exact mfderiv I 𝓘(𝕜, E') g z) :=
16981698
(hf.hasMFDerivAt.sub hg.hasMFDerivAt).mfderiv
16991699
#align mfderiv_sub mfderiv_sub
17001700

0 commit comments

Comments
 (0)