Skip to content

Commit cd11c28

Browse files
committed
chore(Units): better follow the naming convention (#26251)
Moves * `Units.ext` -> `Units.val_injective` * `Units.eq_iff` -> `Units.val_inj`
1 parent db7a73c commit cd11c28

File tree

32 files changed

+64
-59
lines changed

32 files changed

+64
-59
lines changed

Mathlib/Algebra/GCDMonoid/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,7 @@ variable (G₀ : Type*) [CommGroupWithZero G₀] [DecidableEq G₀]
12151215
instance (priority := 100) : NormalizedGCDMonoid G₀ where
12161216
normUnit x := if h : x = 0 then 1 else (Units.mk0 x h)⁻¹
12171217
normUnit_zero := dif_pos rfl
1218-
normUnit_mul {x y} x0 y0 := Units.eq_iff.1 (by simp [x0, y0, mul_comm])
1218+
normUnit_mul {x y} x0 y0 := Units.ext <| by simp [x0, y0, mul_comm]
12191219
normUnit_coe_units u := by simp
12201220
gcd a b := if a = 0 ∧ b = 0 then 0 else 1
12211221
lcm a b := if a = 0 ∨ b = 0 then 0 else 1

Mathlib/Algebra/Group/Center.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ theorem subset_center_units : ((↑) : Mˣ → M) ⁻¹' center M ⊆ Set.center
257257
fun _ ha => by
258258
rw [_root_.Semigroup.mem_center_iff]
259259
intro _
260-
rw [← Units.eq_iff, Units.val_mul, Units.val_mul, ha.comm]
260+
rw [← Units.val_inj, Units.val_mul, Units.val_mul, ha.comm]
261261

262262
@[to_additive (attr := simp)]
263263
theorem units_inv_mem_center {a : Mˣ} (ha : ↑a ∈ Set.center M) : ↑a⁻¹ ∈ Set.center M := by

Mathlib/Algebra/Group/Units/Defs.lean

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ instance instInv : Inv αˣ :=
9292
attribute [instance] AddUnits.instNeg
9393

9494
/-- See Note [custom simps projection] -/
95-
@[to_additive "See Note [custom simps projection]"]
95+
@[to_additive
96+
"See Note [custom simps projection]"]
9697
def Simps.val_inv (u : αˣ) : α := ↑(u⁻¹)
9798

9899
initialize_simps_projections Units (as_prefix val, val_inv → null, inv → val_inv, as_prefix val_inv)
@@ -104,15 +105,20 @@ initialize_simps_projections AddUnits
104105
theorem val_mk (a : α) (b h₁ h₂) : ↑(Units.mk a b h₁ h₂) = a :=
105106
rfl
106107

107-
@[to_additive (attr := ext)]
108-
theorem ext : Function.Injective (val : αˣ → α)
108+
@[to_additive]
109+
theorem val_injective : Function.Injective (val : αˣ → α)
109110
| ⟨v, i₁, vi₁, iv₁⟩, ⟨v', i₂, vi₂, iv₂⟩, e => by
110111
simp only at e; subst v'; congr
111112
simpa only [iv₂, vi₁, one_mul, mul_one] using mul_assoc i₂ v i₁
112113

114+
@[to_additive (attr := ext)]
115+
theorem ext {u v : αˣ} (huv : u.val = v.val) : u = v := val_injective huv
116+
113117
@[to_additive (attr := norm_cast)]
114-
theorem eq_iff {a b : αˣ} : (a : α) = b ↔ a = b :=
115-
ext.eq_iff
118+
theorem val_inj {a b : αˣ} : (a : α) = b ↔ a = b :=
119+
val_injective.eq_iff
120+
121+
@[to_additive (attr := deprecated val_inj (since := "2025-06-21"))] alias eq_iff := val_inj
116122

117123
/-- Units have decidable equality if the base `Monoid` has decidable equality. -/
118124
@[to_additive "Additive units have decidable equality
@@ -173,7 +179,7 @@ theorem val_one : ((1 : αˣ) : α) = 1 :=
173179
rfl
174180

175181
@[to_additive (attr := simp, norm_cast)]
176-
theorem val_eq_one {a : αˣ} : (a : α) = 1 ↔ a = 1 := by rw [← Units.val_one, eq_iff]
182+
theorem val_eq_one {a : αˣ} : (a : α) = 1 ↔ a = 1 := by rw [← Units.val_one, val_inj]
177183

178184
@[to_additive (attr := simp)]
179185
theorem inv_mk (x y : α) (h₁ h₂) : (mk x y h₁ h₂)⁻¹ = mk y x h₂ h₁ :=
@@ -490,7 +496,7 @@ theorem unit_spec (h : IsUnit a) : ↑h.unit = a :=
490496

491497
@[to_additive (attr := simp)]
492498
theorem unit_one (h : IsUnit (1 : M)) : h.unit = 1 :=
493-
Units.eq_iff.1 rfl
499+
Units.ext rfl
494500

495501
@[to_additive]
496502
theorem unit_mul (ha : IsUnit a) (hb : IsUnit b) : (ha.mul hb).unit = ha.unit * hb.unit :=

Mathlib/Algebra/Group/Units/Hom.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ variable {M}
108108
theorem coeHom_apply (x : Mˣ) : coeHom M x = ↑x := rfl
109109

110110
@[to_additive]
111-
theorem coeHom_injective : Function.Injective (coeHom M) :=
112-
Units.ext
111+
theorem coeHom_injective : Function.Injective (coeHom M) := Units.val_injective
113112

114113
section DivisionMonoid
115114

Mathlib/Algebra/Order/Monoid/Units.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ theorem val_lt_val [Monoid α] [Preorder α] {a b : αˣ} : (a : α) < b ↔ a <
2929

3030
@[to_additive]
3131
instance instPartialOrderUnits [Monoid α] [PartialOrder α] : PartialOrder αˣ :=
32-
PartialOrder.lift val Units.ext
32+
PartialOrder.lift val val_injective
3333

3434
@[to_additive]
3535
instance [Monoid α] [LinearOrder α] : LinearOrder αˣ :=
36-
LinearOrder.lift' val Units.ext
36+
LinearOrder.lift' val val_injective
3737

3838
/-- `val : αˣ → α` as an order embedding. -/
3939
@[to_additive (attr := simps -fullyApplied)
4040
"`val : add_units α → α` as an order embedding."]
4141
def orderEmbeddingVal [Monoid α] [LinearOrder α] : αˣ ↪o α :=
42-
⟨⟨val, ext⟩, Iff.rfl⟩
42+
⟨⟨val, val_injective⟩, .rfl⟩
4343

4444
@[to_additive (attr := simp, norm_cast)]
4545
theorem max_val [Monoid α] [LinearOrder α] {a b : αˣ} : (max a b).val = max a.val b.val :=

Mathlib/Algebra/Polynomial/UnitTrinomial.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ theorem irreducible_aux2 {k m m' n : ℕ} (hkm : k < m) (hmn : m < n) (hkm' : k
241241
replace h := h.trans (irreducible_aux1 hkm' hmn' u v w hq).symm
242242
rw [(isUnit_C.mpr v.isUnit).mul_right_inj] at h
243243
rw [binomial_eq_binomial u.ne_zero w.ne_zero] at h
244-
simp only [add_left_inj, Units.eq_iff] at h
244+
simp only [add_left_inj, Units.val_inj] at h
245245
rcases h with (⟨rfl, -⟩ | ⟨rfl, rfl, h⟩ | ⟨-, hm, hm'⟩)
246246
· exact Or.inl (hq.trans hp.symm)
247247
· refine Or.inr ?_
@@ -268,7 +268,7 @@ theorem irreducible_aux3 {k m m' n : ℕ} (hkm : k < m) (hmn : m < n) (hkm' : k
268268
mul_right_inj' (show 2 * (v : ℤ) ≠ 0 from mul_ne_zero two_ne_zero v.ne_zero)] at hadd
269269
replace hadd :=
270270
(Int.isUnit_add_isUnit_eq_isUnit_add_isUnit w.isUnit u.isUnit z.isUnit x.isUnit).mp hadd
271-
simp only [Units.eq_iff] at hadd
271+
simp only [Units.val_inj] at hadd
272272
rcases hadd with (⟨rfl, rfl⟩ | ⟨rfl, rfl⟩)
273273
· exact irreducible_aux2 hkm hmn hkm' hmn' u v w hp hq h
274274
· rw [← mirror_inj, trinomial_mirror hkm' hmn' w.ne_zero u.ne_zero] at hq

Mathlib/Algebra/Ring/Units.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ protected theorem val_neg (u : αˣ) : (↑(-u) : α) = -u :=
3939
protected theorem coe_neg_one : ((-1 : αˣ) : α) = -1 :=
4040
rfl
4141

42-
instance : HasDistribNeg αˣ :=
43-
Units.ext.hasDistribNeg _ Units.val_neg Units.val_mul
42+
instance : HasDistribNeg αˣ := val_injective.hasDistribNeg _ Units.val_neg val_mul
4443

4544
@[field_simps]
4645
theorem neg_divp (a : α) (u : αˣ) : -(a /ₚ u) = -a /ₚ u := by simp only [divp, neg_mul]

Mathlib/Analysis/Complex/Isometry.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,4 @@ theorem det_rotation (a : Circle) : LinearMap.det ((rotation a).toLinearEquiv :
157157
/-- The determinant of `rotation` (as a linear equiv) is equal to `1`. -/
158158
@[simp]
159159
theorem linearEquiv_det_rotation (a : Circle) : LinearEquiv.det (rotation a).toLinearEquiv = 1 := by
160-
rw [← Units.eq_iff, LinearEquiv.coe_det, det_rotation, Units.val_one]
160+
rw [← Units.val_inj, LinearEquiv.coe_det, det_rotation, Units.val_one]

Mathlib/Data/Complex/Determinant.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ theorem det_conjAe : LinearMap.det conjAe.toLinearMap = -1 := by
2626
/-- The determinant of `conjAe`, as a linear equiv. -/
2727
@[simp]
2828
theorem linearEquiv_det_conjAe : LinearEquiv.det conjAe.toLinearEquiv = -1 := by
29-
rw [← Units.eq_iff, LinearEquiv.coe_det, AlgEquiv.toLinearEquiv_toLinearMap, det_conjAe,
29+
rw [← Units.val_inj, LinearEquiv.coe_det, AlgEquiv.toLinearEquiv_toLinearMap, det_conjAe,
3030
Units.coe_neg_one]
3131

3232
end Complex

Mathlib/Data/Fintype/Units.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ theorem Fintype.card_units_int : Fintype.card ℤˣ = 2 := rfl
2828
instance [Monoid α] [Fintype α] [DecidableEq α] : Fintype αˣ :=
2929
Fintype.ofEquiv _ (unitsEquivProdSubtype α).symm
3030

31-
instance [Monoid α] [Finite α] : Finite αˣ := Finite.of_injective _ Units.ext
31+
instance [Monoid α] [Finite α] : Finite αˣ := .of_injective _ Units.val_injective
3232

3333
variable (α)
3434

0 commit comments

Comments
 (0)