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

Commit 84cbbc9

Browse files
adomanialexjbest
andcommitted
feat(algebra/group/to_additive + a few more files): make to_additive convert unit to add_unit (#12564)
This likely involves removing names that match autogenerated names. Co-authored-by: Alex J. Best <alex.j.best@gmail.com>
1 parent 869ef84 commit 84cbbc9

File tree

5 files changed

+18
-17
lines changed

5 files changed

+18
-17
lines changed

src/algebra/group/to_additive.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ meta def tr : bool → list string → list string
225225
| is_comm ("magma" :: s) := ("add_" ++ add_comm_prefix is_comm "magma") :: tr ff s
226226
| is_comm ("haar" :: s) := ("add_" ++ add_comm_prefix is_comm "haar") :: tr ff s
227227
| is_comm ("prehaar" :: s) := ("add_" ++ add_comm_prefix is_comm "prehaar") :: tr ff s
228+
| is_comm ("unit" :: s) := ("add_" ++ add_comm_prefix is_comm "unit") :: tr ff s
229+
| is_comm ("units" :: s) := ("add_" ++ add_comm_prefix is_comm "units") :: tr ff s
228230
| is_comm ("comm" :: s) := tr tt s
229231
| is_comm (x :: s) := (add_comm_prefix is_comm x :: tr ff s)
230232
| tt [] := ["comm"]

src/algebra/group/units.lean

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ structure add_units (α : Type u) [add_monoid α] :=
5353
(val_neg : val + neg = 0)
5454
(neg_val : neg + val = 0)
5555

56-
attribute [to_additive add_units] units
56+
attribute [to_additive] units
5757

5858
section has_elem
5959

@@ -278,12 +278,12 @@ variables {M : Type*} {N : Type*}
278278
/-- An element `a : M` of a monoid is a unit if it has a two-sided inverse.
279279
The actual definition says that `a` is equal to some `u : Mˣ`, where
280280
`Mˣ` is a bundled version of `is_unit`. -/
281-
@[to_additive is_add_unit "An element `a : M` of an add_monoid is an `add_unit` if it has
281+
@[to_additive "An element `a : M` of an add_monoid is an `add_unit` if it has
282282
a two-sided additive inverse. The actual definition says that `a` is equal to some
283283
`u : add_units M`, where `add_units M` is a bundled version of `is_add_unit`."]
284284
def is_unit [monoid M] (a : M) : Prop := ∃ u : Mˣ, (u : M) = a
285285

286-
@[nontriviality, to_additive is_add_unit_of_subsingleton]
286+
@[nontriviality, to_additive]
287287
lemma is_unit_of_subsingleton [monoid M] [subsingleton M] (a : M) : is_unit a :=
288288
⟨⟨a, a, subsingleton.elim _ _, subsingleton.elim _ _⟩, rfl⟩
289289

@@ -301,10 +301,10 @@ attribute [nontriviality] is_add_unit_of_subsingleton
301301
@[simp, to_additive is_add_unit_add_unit]
302302
protected lemma units.is_unit [monoid M] (u : Mˣ) : is_unit (u : M) := ⟨u, rfl⟩
303303

304-
@[simp, to_additive is_add_unit_zero]
304+
@[simp, to_additive]
305305
theorem is_unit_one [monoid M] : is_unit (1:M) := ⟨1, rfl⟩
306306

307-
@[to_additive is_add_unit_of_add_eq_zero] theorem is_unit_of_mul_eq_one [comm_monoid M]
307+
@[to_additive] theorem is_unit_of_mul_eq_one [comm_monoid M]
308308
(a b : M) (h : a * b = 1) : is_unit a :=
309309
⟨units.mk_of_mul_eq_one a b h, rfl⟩
310310

@@ -316,12 +316,12 @@ by { rcases h with ⟨⟨a, b, hab, _⟩, rfl⟩, exact ⟨b, hab⟩ }
316316
{a : M} (h : is_unit a) : ∃ b, b * a = 1 :=
317317
by { rcases h with ⟨⟨a, b, _, hba⟩, rfl⟩, exact ⟨b, hba⟩ }
318318

319-
@[to_additive is_add_unit_iff_exists_neg] theorem is_unit_iff_exists_inv [comm_monoid M]
319+
@[to_additive] theorem is_unit_iff_exists_inv [comm_monoid M]
320320
{a : M} : is_unit a ↔ ∃ b, a * b = 1 :=
321321
⟨λ h, h.exists_right_inv,
322322
λ ⟨b, hab⟩, is_unit_of_mul_eq_one _ b hab⟩
323323

324-
@[to_additive is_add_unit_iff_exists_neg'] theorem is_unit_iff_exists_inv' [comm_monoid M]
324+
@[to_additive] theorem is_unit_iff_exists_inv' [comm_monoid M]
325325
{a : M} : is_unit a ↔ ∃ b, b * a = 1 :=
326326
by simp [is_unit_iff_exists_inv, mul_comm]
327327

@@ -330,7 +330,7 @@ lemma is_unit.mul [monoid M] {x y : M} : is_unit x → is_unit y → is_unit (x
330330
by { rintros ⟨x, rfl⟩ ⟨y, rfl⟩, exact ⟨x * y, units.coe_mul _ _⟩ }
331331

332332
/-- Multiplication by a `u : Mˣ` on the right doesn't affect `is_unit`. -/
333-
@[simp, to_additive is_add_unit_add_add_units "Addition of a `u : add_units M` on the right doesn't
333+
@[simp, to_additive "Addition of a `u : add_units M` on the right doesn't
334334
affect `is_add_unit`."]
335335
theorem units.is_unit_mul_units [monoid M] (a : M) (u : Mˣ) :
336336
is_unit (a * u) ↔ is_unit a :=
@@ -341,8 +341,7 @@ iff.intro
341341
(λ v, v.mul u.is_unit)
342342

343343
/-- Multiplication by a `u : Mˣ` on the left doesn't affect `is_unit`. -/
344-
@[simp, to_additive is_add_unit_add_units_add "Addition of a `u : add_units M` on the left doesn't
345-
affect `is_add_unit`."]
344+
@[simp, to_additive "Addition of a `u : add_units M` on the left doesn't affect `is_add_unit`."]
346345
theorem units.is_unit_units_mul {M : Type*} [monoid M] (u : Mˣ) (a : M) :
347346
is_unit (↑u * a) ↔ is_unit a :=
348347
iff.intro
@@ -351,7 +350,7 @@ iff.intro
351350
by rwa [←mul_assoc, units.inv_mul, one_mul] at this)
352351
u.is_unit.mul
353352

354-
@[to_additive is_add_unit_of_add_is_add_unit_left]
353+
@[to_additive]
355354
theorem is_unit_of_mul_is_unit_left [comm_monoid M] {x y : M}
356355
(hu : is_unit (x * y)) : is_unit x :=
357356
let ⟨z, hz⟩ := is_unit_iff_exists_inv.1 hu in

src/data/equiv/mul_add.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,18 +476,18 @@ def monoid_hom.to_mul_equiv [mul_one_class M] [mul_one_class N] (f : M →* N) (
476476
map_mul' := f.map_mul }
477477

478478
/-- A group is isomorphic to its group of units. -/
479-
@[to_additive to_add_units "An additive group is isomorphic to its group of additive units"]
479+
@[to_additive "An additive group is isomorphic to its group of additive units"]
480480
def to_units [group G] : G ≃* Gˣ :=
481481
{ to_fun := λ x, ⟨x, x⁻¹, mul_inv_self _, inv_mul_self _⟩,
482482
inv_fun := coe,
483483
left_inv := λ x, rfl,
484484
right_inv := λ u, units.ext rfl,
485485
map_mul' := λ x y, units.ext rfl }
486486

487-
@[simp, to_additive coe_to_add_units] lemma coe_to_units [group G] (g : G) :
487+
@[simp, to_additive] lemma coe_to_units [group G] (g : G) :
488488
(to_units g : G) = g := rfl
489489

490-
@[to_additive add_group.is_add_unit]
490+
@[to_additive]
491491
protected lemma group.is_unit {G} [group G] (x : G) : is_unit x := (to_units x).is_unit
492492

493493
namespace units

src/group_theory/congruence.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ variables {α : Type*} [monoid M] {c : con M}
985985
where `c : con M` is a multiplicative congruence on a monoid, it suffices to define a function `f`
986986
that takes elements `x y : M` with proofs of `c (x * y) 1` and `c (y * x) 1`, and returns an element
987987
of `α` provided that `f x y _ _ = f x' y' _ _` whenever `c x x'` and `c y y'`. -/
988-
@[to_additive lift_on_add_units] def lift_on_units (u : units c.quotient)
988+
@[to_additive] def lift_on_units (u : units c.quotient)
989989
(f : Π (x y : M), c (x * y) 1 → c (y * x) 1 → α)
990990
(Hf : ∀ x y hxy hyx x' y' hxy' hyx', c x x' → c y y' → f x y hxy hyx = f x' y' hxy' hyx') :
991991
α :=
@@ -1014,7 +1014,7 @@ lemma lift_on_units_mk (f : Π (x y : M), c (x * y) 1 → c (y * x) 1 → α)
10141014
lift_on_units ⟨(x : c.quotient), y, hxy, hyx⟩ f Hf = f x y (c.eq.1 hxy) (c.eq.1 hyx) :=
10151015
rfl
10161016

1017-
@[elab_as_eliminator, to_additive induction_on_add_units]
1017+
@[elab_as_eliminator, to_additive]
10181018
lemma induction_on_units {p : units c.quotient → Prop} (u : units c.quotient)
10191019
(H : ∀ (x y : M) (hxy : c (x * y) 1) (hyx : c (y * x) 1), p ⟨x, y, c.eq.2 hxy, c.eq.2 hyx⟩) :
10201020
p u :=

src/group_theory/order_of_element.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ by simp_rw [order_of_eq_order_of_iff, ←f.map_pow, ←f.map_one, hf.eq_iff, iff
207207
(y : H) : order_of (y : G) = order_of y :=
208208
order_of_injective H.subtype subtype.coe_injective y
209209

210-
@[to_additive order_of_add_units]
210+
@[to_additive]
211211
lemma order_of_units {y : Gˣ} : order_of (y : G) = order_of y :=
212212
order_of_injective (units.coe_hom G) units.ext y
213213

0 commit comments

Comments
 (0)