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

Commit 86bf83a

Browse files
committed
feat(algebra/ring): mark a useful lemma simp and generalize unit neg lemmas (#16993)
Mark the lemma that states `is_unit (-x) \iff is_unit x` as `simp`, and while we are here generalize a couple of typeclasses to a general monoid with some distributive negation.
1 parent 583cae7 commit 86bf83a

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/algebra/ring/basic.lean

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,9 @@ protected def function.surjective.ring
784784
end ring
785785

786786
namespace units
787-
variables [ring α] {a b : α}
787+
788+
section has_distrib_neg
789+
variables [monoid α] [has_distrib_neg α] {a b : α}
788790

789791
/-- Each element of the group of units of a ring has an additive inverse. -/
790792
instance : has_neg αˣ := ⟨λu, ⟨-↑u, -↑u⁻¹, by simp, by simp⟩ ⟩
@@ -800,6 +802,12 @@ instance : has_distrib_neg αˣ := units.ext.has_distrib_neg _ units.coe_neg uni
800802
@[field_simps] lemma neg_divp (a : α) (u : αˣ) : -(a /ₚ u) = (-a) /ₚ u :=
801803
by simp only [divp, neg_mul]
802804

805+
end has_distrib_neg
806+
807+
section ring
808+
809+
variables [ring α] {a b : α}
810+
803811
@[field_simps] lemma divp_add_divp_same (a b : α) (u : αˣ) :
804812
a /ₚ u + b /ₚ u = (a + b) /ₚ u :=
805813
by simp only [divp, add_mul]
@@ -823,12 +831,15 @@ begin
823831
assoc_rw [units.mul_inv, mul_one],
824832
end
825833

834+
end ring
835+
826836
end units
827837

828-
lemma is_unit.neg [ring α] {a : α} : is_unit a → is_unit (-a)
838+
lemma is_unit.neg [monoid α] [has_distrib_neg α] {a : α} : is_unit a → is_unit (-a)
829839
| ⟨x, hx⟩ := hx ▸ (-x).is_unit
830840

831-
lemma is_unit.neg_iff [ring α] (a : α) : is_unit (-a) ↔ is_unit a :=
841+
@[simp]
842+
lemma is_unit.neg_iff [monoid α] [has_distrib_neg α] (a : α) : is_unit (-a) ↔ is_unit a :=
832843
⟨λ h, neg_neg a ▸ h.neg, is_unit.neg⟩
833844

834845
lemma is_unit.sub_iff [ring α] {x y : α} :

0 commit comments

Comments
 (0)