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

Commit c3f6fce

Browse files
committed
feat(algebra/group_power/basic): add lemmas about pow and neg on units (#11447)
In future we might want to add a typeclass for monoids with a well-behaved negation operator to avoid needing to repeat these lemmas. Such a typeclass would also apply to the `unitary` submonoid too.
1 parent c3d8782 commit c3f6fce

File tree

4 files changed

+106
-9
lines changed

4 files changed

+106
-9
lines changed

src/algebra/group/units_hom.lean

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ variable {M}
4343

4444
@[simp, to_additive] lemma coe_hom_apply (x : Mˣ) : coe_hom M x = ↑x := rfl
4545

46+
@[simp, norm_cast, to_additive]
47+
lemma coe_pow (u : Mˣ) (n : ℕ) : ((u ^ n : Mˣ) : M) = u ^ n :=
48+
(units.coe_hom M).map_pow u n
49+
50+
@[simp, norm_cast, to_additive]
51+
lemma coe_zpow {G} [group G] (u : Gˣ) (n : ℤ) : ((u ^ n : Gˣ) : G) = u ^ n :=
52+
(units.coe_hom G).map_zpow u n
53+
4654
/-- If a map `g : M → Nˣ` agrees with a homomorphism `f : M →* N`, then
4755
this map is a monoid homomorphism too. -/
4856
@[to_additive "If a map `g : M → add_units N` agrees with a homomorphism `f : M →+ N`, then this map

src/algebra/group_power/basic.lean

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,33 @@ by simp [sq]
381381

382382
alias neg_sq ← neg_pow_two
383383

384+
/- Copies of the above ring lemmas for `units R`. -/
385+
namespace units
386+
387+
section
388+
variables (R)
389+
theorem neg_one_pow_eq_or : ∀ n : ℕ, (-1 : Rˣ)^n = 1 ∨ (-1 : Rˣ)^n = -1
390+
| 0 := or.inl (pow_zero _)
391+
| (n+1) := (neg_one_pow_eq_or n).swap.imp
392+
(λ h, by rw [pow_succ, h, ←units.neg_eq_neg_one_mul, units.neg_neg])
393+
(λ h, by rw [pow_succ, h, mul_one])
394+
395+
end
396+
397+
theorem neg_pow (a : Rˣ) (n : ℕ) : (- a) ^ n = (-1) ^ n * a ^ n :=
398+
(units.neg_eq_neg_one_mul a).symm ▸ (commute.units_neg_one_left a).mul_pow n
399+
400+
@[simp] theorem neg_pow_bit0 (a : Rˣ) (n : ℕ) : (- a) ^ (bit0 n) = a ^ (bit0 n) :=
401+
by rw [pow_bit0', units.neg_mul_neg, pow_bit0']
402+
403+
@[simp] theorem neg_pow_bit1 (a : Rˣ) (n : ℕ) : (- a) ^ (bit1 n) = - a ^ (bit1 n) :=
404+
by simp only [bit1, pow_succ, neg_pow_bit0, units.neg_mul_eq_neg_mul]
405+
406+
@[simp] lemma neg_sq (a : Rˣ) : (-a)^2 = a^2 :=
407+
by simp [sq]
408+
409+
end units
410+
384411
end ring
385412

386413
section comm_ring
@@ -400,6 +427,18 @@ by rw [sub_eq_add_neg, add_sq, neg_sq, mul_neg, ← sub_eq_add_neg]
400427

401428
alias sub_sq ← sub_pow_two
402429

430+
/- Copies of the above comm_ring lemmas for `units R`. -/
431+
namespace units
432+
433+
lemma eq_or_eq_neg_of_sq_eq_sq [is_domain R] (a b : Rˣ) (h : a ^ 2 = b ^ 2) : a = b ∨ a = -b :=
434+
begin
435+
refine (eq_or_eq_neg_of_sq_eq_sq _ _ _).imp (λ h, units.ext h) (λ h, units.ext h),
436+
replace h := congr_arg (coe : Rˣ → R) h,
437+
rwa [units.coe_pow, units.coe_pow] at h,
438+
end
439+
440+
end units
441+
403442
end comm_ring
404443

405444
lemma of_add_nsmul [add_monoid A] (x : A) (n : ℕ) :

src/algebra/group_power/lemmas.lean

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ begin
3232
{ simp }
3333
end
3434

35-
@[simp, norm_cast, to_additive]
36-
lemma units.coe_pow (u : Mˣ) (n : ℕ) : ((u ^ n : Mˣ) : M) = u ^ n :=
37-
(units.coe_hom M).map_pow u n
38-
3935
instance invertible_pow (m : M) [invertible m] (n : ℕ) : invertible (m ^ n) :=
4036
{ inv_of := ⅟ m ^ n,
4137
inv_of_mul_self := by rw [← (commute_inv_of m).symm.mul_pow, inv_of_mul_self, one_pow],
@@ -171,10 +167,6 @@ theorem zpow_bit0 (a : G) (n : ℤ) : a ^ bit0 n = a ^ n * a ^ n := zpow_add _ _
171167
theorem zpow_bit1 (a : G) (n : ℤ) : a ^ bit1 n = a ^ n * a ^ n * a :=
172168
by rw [bit1, zpow_add, zpow_bit0, zpow_one]
173169

174-
@[simp, norm_cast, to_additive]
175-
lemma units.coe_zpow (u : Gˣ) (n : ℤ) : ((u ^ n : Gˣ) : G) = u ^ n :=
176-
(units.coe_hom G).map_zpow u n
177-
178170
end group
179171

180172
section ordered_add_comm_group

src/algebra/ring/basic.lean

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,15 @@ units.ext $ neg_mul _ _
803803
/-- Multiplication of elements of a ring's unit group commutes with mapping the second argument
804804
to its additive inverse. -/
805805
@[simp] protected theorem mul_neg (u₁ u₂ : αˣ) : u₁ * -u₂ = -(u₁ * u₂) :=
806-
units.ext $ (neg_mul_eq_mul_neg _ _).symm
806+
units.ext $ mul_neg _ _
807+
808+
/-- `units` version of `neg_mul_eq_neg_mul`. -/
809+
lemma neg_mul_eq_neg_mul (a b : αˣ) : -(a * b) = -a * b :=
810+
units.ext $ neg_mul_eq_neg_mul _ _
811+
812+
/-- `units` version of `neg_mul_eq_mul_neg`. -/
813+
lemma neg_mul_eq_mul_neg (a b : αˣ) : -(a * b) = a * -b :=
814+
units.ext $ neg_mul_eq_mul_neg _ _
807815

808816
/-- Multiplication of the additive inverses of two elements of a ring's unit group equals
809817
multiplication of the two original elements. -/
@@ -813,6 +821,10 @@ units.ext $ (neg_mul_eq_mul_neg _ _).symm
813821
one times the original element. -/
814822
protected theorem neg_eq_neg_one_mul (u : αˣ) : -u = -1 * u := by simp
815823

824+
lemma mul_neg_one (a : α) : a * -1 = -a := by simp
825+
826+
lemma neg_one_mul (a : α) : -1 * a = -a := by simp
827+
816828
end units
817829

818830
lemma is_unit.neg [ring α] {a : α} : is_unit a → is_unit (-a)
@@ -1141,6 +1153,7 @@ by simp only [semiconj_by, left_distrib, right_distrib, h.eq, h'.eq]
11411153
semiconj_by (a + b) x y :=
11421154
by simp only [semiconj_by, left_distrib, right_distrib, ha.eq, hb.eq]
11431155

1156+
section
11441157
variables [ring R] {a b x y x' y' : R}
11451158

11461159
lemma neg_right (h : semiconj_by a x y) : semiconj_by a (-x) (-y) :=
@@ -1169,6 +1182,32 @@ by simpa only [sub_eq_add_neg] using h.add_right h'.neg_right
11691182
semiconj_by (a - b) x y :=
11701183
by simpa only [sub_eq_add_neg] using ha.add_left hb.neg_left
11711184

1185+
end
1186+
1187+
/- Copies of the above ring lemmas for `units R`. -/
1188+
section units
1189+
variables [ring R] {a b x y x' y' : Rˣ}
1190+
1191+
lemma units_neg_right (h : semiconj_by a x y) : semiconj_by a (-x) (-y) :=
1192+
by simp only [semiconj_by, h.eq, units.neg_mul, units.mul_neg]
1193+
1194+
@[simp] lemma units_neg_right_iff : semiconj_by a (-x) (-y) ↔ semiconj_by a x y :=
1195+
⟨λ h, units.neg_neg x ▸ units.neg_neg y ▸ h.units_neg_right, semiconj_by.units_neg_right⟩
1196+
1197+
lemma units_neg_left (h : semiconj_by a x y) : semiconj_by (-a) x y :=
1198+
by simp only [semiconj_by, h.eq, units.neg_mul, units.mul_neg]
1199+
1200+
@[simp] lemma units_neg_left_iff : semiconj_by (-a) x y ↔ semiconj_by a x y :=
1201+
⟨λ h, units.neg_neg a ▸ h.units_neg_left, semiconj_by.units_neg_left⟩
1202+
1203+
@[simp] lemma units_neg_one_right (a : Rˣ) : semiconj_by a (-1) (-1) :=
1204+
(one_right a).units_neg_right
1205+
1206+
@[simp] lemma units_neg_one_left (x : Rˣ) : semiconj_by (-1) x x :=
1207+
(semiconj_by.one_left x).units_neg_left
1208+
1209+
end units
1210+
11721211
end semiconj_by
11731212

11741213
namespace commute
@@ -1193,6 +1232,7 @@ h.bit0_right.add_right (commute.one_right x)
11931232
lemma bit1_left [semiring R] {x y : R} (h : commute x y) : commute (bit1 x) y :=
11941233
h.bit0_left.add_left (commute.one_left y)
11951234

1235+
section
11961236
variables [ring R] {a b c : R}
11971237

11981238
theorem neg_right : commute a b → commute a (- b) := semiconj_by.neg_right
@@ -1207,4 +1247,22 @@ theorem neg_left : commute a b → commute (- a) b := semiconj_by.neg_left
12071247
@[simp] theorem sub_right : commute a b → commute a c → commute a (b - c) := semiconj_by.sub_right
12081248
@[simp] theorem sub_left : commute a c → commute b c → commute (a - b) c := semiconj_by.sub_left
12091249

1250+
end
1251+
1252+
/- Copies of the above ring lemmas for `units R`. -/
1253+
section units
1254+
variables [ring R] {a b c : Rˣ}
1255+
1256+
theorem units_neg_right : commute a b → commute a (- b) := semiconj_by.units_neg_right
1257+
@[simp] theorem units_neg_right_iff : commute a (-b) ↔ commute a b :=
1258+
semiconj_by.units_neg_right_iff
1259+
1260+
theorem units_neg_left : commute a b → commute (- a) b := semiconj_by.units_neg_left
1261+
@[simp] theorem units_neg_left_iff : commute (-a) b ↔ commute a b := semiconj_by.units_neg_left_iff
1262+
1263+
@[simp] theorem units_neg_one_right (a : Rˣ) : commute a (-1) := semiconj_by.units_neg_one_right a
1264+
@[simp] theorem units_neg_one_left (a : Rˣ) : commute (-1) a := semiconj_by.units_neg_one_left a
1265+
1266+
end units
1267+
12101268
end commute

0 commit comments

Comments
 (0)