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

Commit 0a7ff10

Browse files
committed
feat(algebra/units): some norm_cast attributes (#2612)
1 parent 93a64da commit 0a7ff10

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

src/algebra/group/units.lean

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Authors: Kenny Lau, Mario Carneiro, Johannes, Hölzl, Chris Hughes
55
-/
66
import logic.function
77
import algebra.group.to_additive
8+
import tactic.norm_cast
89

910
/-!
1011
# Units (i.e., invertible elements) of a multiplicative monoid
@@ -66,10 +67,17 @@ ext.eq_iff.symm
6667
mul_left_inv := λ u, ext u.inv_val }
6768

6869
variables (a b : units α) {c : units α}
69-
@[simp, to_additive] lemma coe_mul : (↑(a * b) : α) = a * b := rfl
70-
@[simp, to_additive] lemma coe_one : ((1 : units α) : α) = 1 := rfl
70+
@[simp, norm_cast, to_additive] lemma coe_mul : (↑(a * b) : α) = a * b := rfl
71+
attribute [norm_cast] add_units.coe_add
72+
73+
@[simp, norm_cast, to_additive] lemma coe_one : ((1 : units α) : α) = 1 := rfl
74+
attribute [norm_cast] add_units.coe_zero
75+
7176
@[to_additive] lemma val_coe : (↑a : α) = a.val := rfl
72-
@[to_additive] lemma coe_inv : ((a⁻¹ : units α) : α) = a.inv := rfl
77+
78+
@[norm_cast, to_additive] lemma coe_inv : ((a⁻¹ : units α) : α) = a.inv := rfl
79+
attribute [norm_cast] add_units.coe_neg
80+
7381
@[simp, to_additive] lemma inv_mul : (↑a⁻¹ * a : α) = 1 := inv_val _
7482
@[simp, to_additive] lemma mul_inv : (a * ↑a⁻¹ : α) = 1 := val_inv _
7583

src/algebra/group_power.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ theorem is_add_monoid_hom.map_smul (f : A → B) [is_add_monoid_hom f] (a : A) (
155155
f (n • a) = n • f a :=
156156
(add_monoid_hom.of f).map_smul a n
157157

158-
@[simp] lemma units.coe_pow (u : units M) (n : ℕ) : ((u ^ n : units M) : M) = u ^ n :=
158+
@[simp, norm_cast] lemma units.coe_pow (u : units M) (n : ℕ) : ((u ^ n : units M) : M) = u ^ n :=
159159
(units.coe_hom M).map_pow u n
160160

161161
end monoid

src/group_theory/subgroup.lean

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,14 @@ instance subtype.group {s : set G} [is_subgroup s] : group s :=
6060
instance subtype.comm_group {G : Type*} [comm_group G] {s : set G} [is_subgroup s] : comm_group s :=
6161
{ .. subtype.group, .. subtype.comm_monoid }
6262

63-
@[simp, to_additive]
63+
@[simp, norm_cast, to_additive]
6464
lemma is_subgroup.coe_inv {s : set G} [is_subgroup s] (a : s) : ((a⁻¹ : s) : G) = a⁻¹ := rfl
65+
attribute [norm_cast] is_add_subgroup.coe_neg
6566

66-
@[simp] lemma is_subgroup.coe_gpow {s : set G} [is_subgroup s] (a : s) (n : ℤ) : ((a ^ n : s) : G) = a ^ n :=
67+
@[simp, norm_cast] lemma is_subgroup.coe_gpow {s : set G} [is_subgroup s] (a : s) (n : ℤ) : ((a ^ n : s) : G) = a ^ n :=
6768
by induction n; simp [is_submonoid.coe_pow a]
6869

69-
@[simp] lemma is_add_subgroup.gsmul_coe {s : set A} [is_add_subgroup s] (a : s) (n : ℤ) :
70+
@[simp, norm_cast] lemma is_add_subgroup.gsmul_coe {s : set A} [is_add_subgroup s] (a : s) (n : ℤ) :
7071
((gsmul n a : s) : A) = gsmul n a :=
7172
by induction n; simp [is_add_submonoid.smul_coe a]
7273
attribute [to_additive gsmul_coe] is_subgroup.coe_gpow

src/group_theory/submonoid.lean

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,20 +237,22 @@ instance subtype.comm_monoid {M} [comm_monoid M] {s : set M} [is_submonoid s] :
237237
.. subtype.monoid }
238238

239239
/-- Submonoids inherit the 1 of the monoid. -/
240-
@[simp, to_additive "An `add_submonoid` inherits the 0 of the `add_monoid`. "]
240+
@[simp, norm_cast, to_additive "An `add_submonoid` inherits the 0 of the `add_monoid`. "]
241241
lemma is_submonoid.coe_one [is_submonoid s] : ((1 : s) : M) = 1 := rfl
242+
attribute [norm_cast] is_add_submonoid.coe_zero
242243

243244
/-- Submonoids inherit the multiplication of the monoid. -/
244-
@[simp, to_additive "An `add_submonoid` inherits the addition of the `add_monoid`. "]
245+
@[simp, norm_cast, to_additive "An `add_submonoid` inherits the addition of the `add_monoid`. "]
245246
lemma is_submonoid.coe_mul [is_submonoid s] (a b : s) : ((a * b : s) : M) = a * b := rfl
247+
attribute [norm_cast] is_add_submonoid.coe_add
246248

247249
/-- Submonoids inherit the exponentiation by naturals of the monoid. -/
248-
@[simp] lemma is_submonoid.coe_pow [is_submonoid s] (a : s) (n : ℕ) :
250+
@[simp, norm_cast] lemma is_submonoid.coe_pow [is_submonoid s] (a : s) (n : ℕ) :
249251
((a ^ n : s) : M) = a ^ n :=
250252
by induction n; simp [*, pow_succ]
251253

252254
/-- An `add_submonoid` inherits the multiplication by naturals of the `add_monoid`. -/
253-
@[simp] lemma is_add_submonoid.smul_coe {A : Type*} [add_monoid A] {s : set A}
255+
@[simp, norm_cast] lemma is_add_submonoid.smul_coe {A : Type*} [add_monoid A] {s : set A}
254256
[is_add_submonoid s] (a : s) (n : ℕ) : ((add_monoid.smul n a : s) : A) = add_monoid.smul n a :=
255257
by {induction n, refl, simp [*, succ_smul]}
256258

0 commit comments

Comments
 (0)