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

Commit 84f12be

Browse files
committed
chore(algebra/star/self_adjoint): improve definitional unfolding of pow and div (#12085)
1 parent 834fd30 commit 84f12be

File tree

1 file changed

+42
-23
lines changed

1 file changed

+42
-23
lines changed

src/algebra/star/self_adjoint.lean

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,12 @@ by simp only [mem_iff, star_bit0, mem_iff.mp hx]
7171

7272
end add_group
7373

74-
instance [add_comm_group R] [star_add_monoid R] : add_comm_group (self_adjoint R) :=
75-
{ add_comm := add_comm,
76-
..add_subgroup.to_add_group (self_adjoint R) }
77-
7874
section ring
7975
variables [ring R] [star_ring R]
8076

8177
instance : has_one (self_adjoint R) := ⟨⟨1, by rw [mem_iff, star_one]⟩⟩
8278

83-
@[simp, norm_cast] lemma coe_one : (coe : self_adjoint R → R) (1 : self_adjoint R) = (1 : R) := rfl
79+
@[simp, norm_cast] lemma coe_one : (1 : self_adjoint R) = (1 : R) := rfl
8480

8581
instance [nontrivial R] : nontrivial (self_adjoint R) := ⟨⟨0, 1, subtype.ne_of_val_ne zero_ne_one⟩⟩
8682

@@ -103,36 +99,59 @@ variables [comm_ring R] [star_ring R]
10399
instance : has_mul (self_adjoint R) :=
104100
⟨λ x y, ⟨(x : R) * y, by simp only [mem_iff, star_mul', star_coe_eq]⟩⟩
105101

106-
@[simp, norm_cast] lemma coe_mul (x y : self_adjoint R) :
107-
(coe : self_adjoint R → R) (x * y) = (x : R) * y := rfl
102+
@[simp, norm_cast] lemma coe_mul (x y : self_adjoint R) : ↑(x * y) = (x : R) * y := rfl
103+
104+
instance : has_pow (self_adjoint R) ℕ :=
105+
⟨λ x n, ⟨(x : R) ^ n, by simp only [mem_iff, star_pow, star_coe_eq]⟩⟩
106+
107+
@[simp, norm_cast] lemma coe_pow (x : self_adjoint R) (n : ℕ) : ↑(x ^ n) = (x : R) ^ n := rfl
108108

109109
instance : comm_ring (self_adjoint R) :=
110-
{ mul_assoc := λ x y z, by { ext, exact mul_assoc _ _ _ },
111-
one_mul := λ x, by { ext, simp only [coe_mul, one_mul, coe_one] },
112-
mul_one := λ x, by { ext, simp only [mul_one, coe_mul, coe_one] },
113-
mul_comm := λ x y, by { ext, exact mul_comm _ _ },
114-
left_distrib := λ x y z, by { ext, exact left_distrib _ _ _ },
115-
right_distrib := λ x y z, by { ext, exact right_distrib _ _ _ },
116-
..self_adjoint.add_comm_group,
117-
..self_adjoint.has_one,
118-
..self_adjoint.has_mul }
110+
{ npow := λ n x, x ^ n,
111+
nsmul := (•),
112+
zsmul := (•),
113+
-- note: we have to do this in four pieces because there is no `injective.comm_ring_pow`.
114+
..(function.injective.monoid_pow _ subtype.coe_injective coe_one coe_mul coe_pow :
115+
monoid (self_adjoint R)),
116+
..(function.injective.distrib _ subtype.coe_injective (self_adjoint R).coe_add coe_mul :
117+
distrib (self_adjoint R)),
118+
..(function.injective.comm_semigroup _ subtype.coe_injective coe_mul :
119+
comm_semigroup (self_adjoint R)),
120+
..(self_adjoint R).to_add_comm_group }
119121

120122
end comm_ring
121123

122124
section field
123125

124126
variables [field R] [star_ring R]
125127

128+
instance : has_inv (self_adjoint R) :=
129+
{ inv := λ x, ⟨(x.val)⁻¹, by simp only [mem_iff, star_inv', star_coe_eq, subtype.val_eq_coe]⟩ }
130+
131+
@[simp, norm_cast] lemma coe_inv (x : self_adjoint R) : ↑(x⁻¹) = (x : R)⁻¹ := rfl
132+
133+
instance : has_div (self_adjoint R) :=
134+
{ div := λ x y, ⟨x / y, by simp only [mem_iff, star_div', star_coe_eq, subtype.val_eq_coe]⟩ }
135+
136+
@[simp, norm_cast] lemma coe_div (x y : self_adjoint R) : ↑(x / y) = (x / y : R) := rfl
137+
138+
instance : has_pow (self_adjoint R) ℤ :=
139+
{ pow := λ x z, ⟨x ^ z, by simp only [mem_iff, star_zpow₀, star_coe_eq, subtype.val_eq_coe]⟩ }
140+
141+
@[simp, norm_cast] lemma coe_zpow (x : self_adjoint R) (z : ℤ) : ↑(x ^ z) = (x : R) ^ z := rfl
142+
126143
instance : field (self_adjoint R) :=
127-
{ inv := λ x, ⟨(x.val)⁻¹, by simp only [mem_iff, star_inv', star_coe_eq, subtype.val_eq_coe]⟩,
128-
exists_pair_ne := ⟨0, 1, subtype.ne_of_val_ne zero_ne_one⟩,
129-
mul_inv_cancel := λ x hx, by { ext, exact mul_inv_cancel (λ H, hx $ subtype.eq H) },
130-
inv_zero := by { ext, exact inv_zero },
144+
{ npow := λ n x, x ^ n,
145+
zpow := λ z x, x ^ z,
146+
nsmul := (•),
147+
zsmul := (•),
148+
-- note: we have to do this in three pieces because there is no `injective.field_pow`.
149+
..(function.injective.div_inv_monoid_pow _ subtype.coe_injective _ _ coe_inv coe_div _ coe_zpow :
150+
div_inv_monoid (self_adjoint R)),
151+
..(function.injective.group_with_zero _ subtype.coe_injective (self_adjoint R).coe_zero _ _ _ _ :
152+
group_with_zero (self_adjoint R)),
131153
..self_adjoint.comm_ring }
132154

133-
@[simp, norm_cast] lemma coe_inv (x : self_adjoint R) :
134-
(coe : self_adjoint R → R) (x⁻¹) = (x : R)⁻¹ := rfl
135-
136155
end field
137156

138157
section has_scalar

0 commit comments

Comments
 (0)