Skip to content

Commit ce6b0a9

Browse files
committed
refactor: Unify the different versions of mul_eq_one (#14996)
Replace `mul_eq_one_iff` and `Associates.mul_eq_one_iff` by a single lemma `mul_eq_one`. Rename `mul_eq_one_iff'` to `mul_eq_one_iff_of_one_le`. Similarly for the additive versions.
1 parent bc89bc5 commit ce6b0a9

File tree

32 files changed

+61
-60
lines changed

32 files changed

+61
-60
lines changed

Archive/Wiedijk100Theorems/BallotProblem.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ theorem ballot_problem :
365365
exacts [Nat.cast_le.2 qp.le, ENNReal.natCast_ne_top _]
366366
rwa [ENNReal.toReal_eq_toReal (measure_lt_top _ _).ne] at this
367367
simp only [Ne, ENNReal.div_eq_top, tsub_eq_zero_iff_le, Nat.cast_le, not_le,
368-
add_eq_zero_iff, Nat.cast_eq_zero, ENNReal.add_eq_top, ENNReal.natCast_ne_top, or_self_iff,
368+
add_eq_zero, Nat.cast_eq_zero, ENNReal.add_eq_top, ENNReal.natCast_ne_top, or_self_iff,
369369
not_false_iff, and_true_iff]
370370
push_neg
371371
exact ⟨fun _ _ => by linarith, (tsub_le_self.trans_lt (ENNReal.natCast_ne_top p).lt_top).ne⟩

Mathlib/Algebra/Associated/Basic.lean

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -844,20 +844,15 @@ theorem mk_pow (a : α) (n : ℕ) : Associates.mk (a ^ n) = Associates.mk a ^ n
844844
theorem dvd_eq_le : ((· ∣ ·) : Associates α → Associates α → Prop) = (· ≤ ·) :=
845845
rfl
846846

847-
theorem mul_eq_one_iff {x y : Associates α} : x * y = 1 ↔ x = 1 ∧ y = 1 :=
848-
Iff.intro
849-
(Quotient.inductionOn₂ x y fun a b h =>
850-
have : a * b ~ᵤ 1 := Quotient.exact h
851-
⟨Quotient.sound <| associated_one_of_associated_mul_one this,
852-
Quotient.sound <| associated_one_of_associated_mul_one (b := a) (by rwa [mul_comm])⟩)
853-
(by simp (config := { contextual := true }))
854-
855-
theorem units_eq_one (u : (Associates α)ˣ) : u = 1 :=
856-
Units.ext (mul_eq_one_iff.1 u.val_inv).1
857-
858847
instance uniqueUnits : Unique (Associates α)ˣ where
859-
default := 1
860-
uniq := Associates.units_eq_one
848+
uniq := by
849+
rintro ⟨a, b, hab, hba⟩
850+
revert hab hba
851+
exact Quotient.inductionOn₂ a b $ fun a b hab hba ↦ Units.ext $ Quotient.sound $
852+
associated_one_of_associated_mul_one $ Quotient.exact hab
853+
854+
@[deprecated (since := "2024-07-22")] alias mul_eq_one_iff := mul_eq_one
855+
@[deprecated (since := "2024-07-22")] protected alias units_eq_one := Subsingleton.elim
861856

862857
@[simp]
863858
theorem coe_unit_eq_one (u : (Associates α)ˣ) : (u : Associates α) = 1 := by

Mathlib/Algebra/BigOperators/Associated.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ theorem rel_associated_iff_map_eq_map {p q : Multiset α} :
129129
theorem prod_eq_one_iff {p : Multiset (Associates α)} :
130130
p.prod = 1 ↔ ∀ a ∈ p, (a : Associates α) = 1 :=
131131
Multiset.induction_on p (by simp)
132-
(by simp (config := { contextual := true }) [mul_eq_one_iff, or_imp, forall_and])
132+
(by simp (config := { contextual := true }) [mul_eq_one, or_imp, forall_and])
133133

134134
theorem prod_le_prod {p q : Multiset (Associates α)} (h : p ≤ q) : p.prod ≤ q.prod := by
135135
haveI := Classical.decEq (Associates α)
@@ -146,7 +146,7 @@ variable [CancelCommMonoidWithZero α]
146146

147147
theorem exists_mem_multiset_le_of_prime {s : Multiset (Associates α)} {p : Associates α}
148148
(hp : Prime p) : p ≤ s.prod → ∃ a ∈ s, p ≤ a :=
149-
Multiset.induction_on s (fun ⟨d, Eq⟩ => (hp.ne_one (mul_eq_one_iff.1 Eq.symm).1).elim)
149+
Multiset.induction_on s (fun ⟨d, Eq⟩ => (hp.ne_one (mul_eq_one.1 Eq.symm).1).elim)
150150
fun a s ih h =>
151151
have : p ≤ a * s.prod := by simpa using h
152152
match Prime.le_or_le hp this with

Mathlib/Algebra/Order/BigOperators/Group/Finset.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ theorem prod_eq_one_iff_of_one_le' :
147147
(fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_empty _ h), fun _ ↦ rfl⟩) ?_
148148
intro a s ha ih H
149149
have : ∀ i ∈ s, 1 ≤ f i := fun _ ↦ H _ ∘ mem_insert_of_mem
150-
rw [prod_insert ha, mul_eq_one_iff' (H _ <| mem_insert_self _ _) (one_le_prod' this),
150+
rw [prod_insert ha, mul_eq_one_iff_of_one_le (H _ <| mem_insert_self _ _) (one_le_prod' this),
151151
forall_mem_insert, ih this]
152152

153153
@[to_additive sum_eq_zero_iff_of_nonpos]

Mathlib/Algebra/Order/Monoid/Canonical/Defs.lean

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Copyright (c) 2016 Jeremy Avigad. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Jeremy Avigad, Leonardo de Moura, Mario Carneiro, Johannes Hölzl
55
-/
6+
import Mathlib.Algebra.Group.Units
67
import Mathlib.Algebra.Order.Monoid.Defs
78
import Mathlib.Algebra.Order.Monoid.Unbundled.ExistsOfLE
89
import Mathlib.Algebra.NeZero
@@ -110,11 +111,11 @@ theorem one_le (a : α) : 1 ≤ a :=
110111
theorem bot_eq_one : (⊥ : α) = 1 :=
111112
le_antisymm bot_le (one_le ⊥)
112113

113-
--TODO: This is a special case of `mul_eq_one`. We need the instance
114-
-- `CanonicallyOrderedCommMonoid α → Unique αˣ`
115-
@[to_additive (attr := simp)]
116-
theorem mul_eq_one_iff : a * b = 1 ↔ a = 1 ∧ b = 1 :=
117-
mul_eq_one_iff' (one_le _) (one_le _)
114+
@[to_additive] instance CanonicallyOrderedCommMonoid.toUniqueUnits : Unique αˣ where
115+
uniq a := Units.ext ((mul_eq_one_iff_of_one_le (α := α) (one_le _) $ one_le _).1 a.mul_inv).1
116+
117+
@[deprecated (since := "2024-07-24")] alias mul_eq_one_iff := mul_eq_one
118+
@[deprecated (since := "2024-07-24")] alias add_eq_zero_iff := add_eq_zero
118119

119120
@[to_additive (attr := simp)]
120121
theorem le_one_iff_eq_one : a ≤ 1 ↔ a = 1 :=
@@ -129,7 +130,7 @@ theorem eq_one_or_one_lt (a : α) : a = 1 ∨ 1 < a := (one_le a).eq_or_lt.imp_l
129130

130131
@[to_additive (attr := simp) add_pos_iff]
131132
theorem one_lt_mul_iff : 1 < a * b ↔ 1 < a ∨ 1 < b := by
132-
simp only [one_lt_iff_ne_one, Ne, mul_eq_one_iff, not_and_or]
133+
simp only [one_lt_iff_ne_one, Ne, mul_eq_one, not_and_or]
133134

134135
@[to_additive]
135136
theorem exists_one_lt_mul_of_lt (h : a < b) : ∃ (c : _) (_ : 1 < c), a * c = b := by

Mathlib/Algebra/Order/Monoid/Unbundled/Basic.lean

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ section PartialOrder
954954
variable [PartialOrder α]
955955

956956
@[to_additive]
957-
theorem mul_eq_one_iff' [CovariantClass α α (· * ·) (· ≤ ·)]
957+
theorem mul_eq_one_iff_of_one_le [CovariantClass α α (· * ·) (· ≤ ·)]
958958
[CovariantClass α α (swap (· * ·)) (· ≤ ·)] {a b : α} (ha : 1 ≤ a) (hb : 1 ≤ b) :
959959
a * b = 1 ↔ a = 1 ∧ b = 1 :=
960960
Iff.intro
@@ -969,6 +969,9 @@ theorem mul_eq_one_iff' [CovariantClass α α (· * ·) (· ≤ ·)]
969969
-- `fun ⟨ha', hb'⟩ => by rw [ha', hb', mul_one]`,
970970
-- had its `to_additive`-ization fail due to some bug
971971

972+
@[deprecated (since := "2024-07-24")] alias mul_eq_one_iff' := mul_eq_one_iff_of_one_le
973+
@[deprecated (since := "2024-07-24")] alias add_eq_zero_iff' := add_eq_zero_iff_of_nonneg
974+
972975
section Left
973976

974977
variable [CovariantClass α α (· * ·) (· ≤ ·)] {a b : α}

Mathlib/Algebra/Order/Ring/Unbundled/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ lemma mul_self_add_mul_self_eq_zero [IsRightCancelAdd α] [NoZeroDivisors α]
915915
[ZeroLEOneClass α] [ExistsAddOfLE α] [PosMulMono α]
916916
[CovariantClass α α (· + ·) (· ≤ ·)] [CovariantClass α α (· + ·) (· < ·)] :
917917
a * a + b * b = 0 ↔ a = 0 ∧ b = 0 := by
918-
rw [add_eq_zero_iff', mul_self_eq_zero (M₀ := α), mul_self_eq_zero (M₀ := α)] <;>
918+
rw [add_eq_zero_iff_of_nonneg, mul_self_eq_zero (M₀ := α), mul_self_eq_zero (M₀ := α)] <;>
919919
apply mul_self_nonneg
920920

921921
lemma eq_zero_of_mul_self_add_mul_self_eq_zero [IsRightCancelAdd α] [NoZeroDivisors α]

Mathlib/Algebra/Polynomial/Monic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ theorem Monic.eq_one_of_isUnit (hm : Monic p) (hpu : IsUnit p) : p = 1 := by
220220
nontriviality R
221221
obtain ⟨q, h⟩ := hpu.exists_right_inv
222222
have := hm.natDegree_mul' (right_ne_zero_of_mul_eq_one h)
223-
rw [h, natDegree_one, eq_comm, add_eq_zero_iff] at this
223+
rw [h, natDegree_one, eq_comm, add_eq_zero] at this
224224
exact hm.natDegree_eq_zero_iff_eq_one.mp this.1
225225

226226
theorem Monic.isUnit_iff (hm : p.Monic) : IsUnit p ↔ p = 1 :=

Mathlib/Algebra/Polynomial/RingDivision.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ theorem natDegree_eq_zero_of_isUnit (h : IsUnit p) : natDegree p = 0 := by
179179
nontriviality R
180180
obtain ⟨q, hq⟩ := h.exists_right_inv
181181
have := natDegree_mul (left_ne_zero_of_mul_eq_one hq) (right_ne_zero_of_mul_eq_one hq)
182-
rw [hq, natDegree_one, eq_comm, add_eq_zero_iff] at this
182+
rw [hq, natDegree_one, eq_comm, add_eq_zero] at this
183183
exact this.1
184184

185185
theorem degree_eq_zero_of_isUnit [Nontrivial R] (h : IsUnit p) : degree p = 0 :=

Mathlib/Algebra/Quaternion.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,8 @@ variable [LinearOrderedCommRing R] {a : ℍ[R]}
11701170
@[simp]
11711171
theorem normSq_eq_zero : normSq a = 0 ↔ a = 0 := by
11721172
refine ⟨fun h => ?_, fun h => h.symm ▸ normSq.map_zero⟩
1173-
rw [normSq_def', add_eq_zero_iff', add_eq_zero_iff', add_eq_zero_iff'] at h
1173+
rw [normSq_def', add_eq_zero_iff_of_nonneg, add_eq_zero_iff_of_nonneg, add_eq_zero_iff_of_nonneg]
1174+
at h
11741175
· exact ext a 0 (pow_eq_zero h.1.1.1) (pow_eq_zero h.1.1.2) (pow_eq_zero h.1.2) (pow_eq_zero h.2)
11751176
all_goals apply_rules [sq_nonneg, add_nonneg]
11761177

0 commit comments

Comments
 (0)