Skip to content

Commit e3b828e

Browse files
committed
chore(Order/Def): avoid relying on internal class projections in other files (leanprover-community#31808)
This PR removes references to lemmas that are class projections of `Preorder`, `PartialOrder` or `LinearOrder`. Instead, the global namespace lemmas should be used. To avoid accidentally referring to these lemmas, they are marked as `protected`. I hope that it will be possible to hide these lemmas from the imports, using the module system. See https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Should.20duplicated.20class.20projections.20be.20private.3F/with/558208782
1 parent 585719a commit e3b828e

11 files changed

Lines changed: 27 additions & 27 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ theorem trichotomy_of_mul_eq_mul
331331
(h : a * b = c * d) : (a = c ∧ b = d) ∨ a < c ∨ b < d := by
332332
obtain hac | rfl | hca := lt_trichotomy a c
333333
· grind
334-
· left; simpa using mul_right_inj_of_comparable (LinearOrder.le_total d b) |>.1 h
334+
· left; simpa using mul_right_inj_of_comparable (le_total d b) |>.1 h
335335
· obtain hbd | rfl | hdb := lt_trichotomy b d
336336
· grind
337337
· exact False.elim <| ne_of_lt (mul_lt_mul_left hca b) h.symm

Mathlib/Analysis/SpecialFunctions/MulExpNegMulSqIntegral.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ theorem tendsto_integral_mul_one_add_inv_smul_sq_pow (g : E →ᵇ ℝ) (hε : 0
107107
(div_nonneg (mul_nonneg (le_of_lt hε) (mul_self_nonneg (g x))) (le_of_lt hnpos)))⟩
108108
apply le_trans (by linarith) (sub_nonneg_of_le ((div_le_one hnpos).mpr _))
109109
apply le_trans (le_trans _ (le_of_lt hgN)) (Nat.cast_le.mpr hn)
110-
apply mul_le_mul (Preorder.le_refl ε) _ (mul_self_nonneg (g x)) (le_of_lt hε)
110+
apply mul_le_mul (le_refl ε) _ (mul_self_nonneg (g x)) (le_of_lt hε)
111111
rw [← abs_le_iff_mul_self_le, abs_norm]
112112
exact norm_coe_le_norm g x
113113
· apply Eventually.of_forall

Mathlib/CategoryTheory/Category/Preorder.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ See `CategoryTheory.homOfLE` and `CategoryTheory.leOfHom`. -/
4848
instance (priority := 100) smallCategory (α : Type u) [Preorder α] : SmallCategory α where
4949
Hom U V := ULift (PLift (U ≤ V))
5050
id X := ⟨⟨le_refl X⟩⟩
51-
comp f g := ⟨⟨le_trans _ _ _ f.down.down g.down.down⟩⟩
51+
comp f g := ⟨⟨le_trans f.down.down g.down.down⟩⟩
5252

5353
instance subsingleton_hom {α : Type u} [Preorder α] (U V : α) : Subsingleton (U ⟶ V) :=
5454
fun _ _ => ULift.ext _ _ (Subsingleton.elim _ _ )⟩

Mathlib/CategoryTheory/SmallObject/Iteration/FunctorOfCocone.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,14 @@ lemma ofCoconeObjIso_hom_naturality (i₁ i₂ : J) (hi : i₁ ≤ i₂) (hi₂
138138
when `c : Cocone F`. -/
139139
@[simps!]
140140
def restrictionLTOfCoconeIso :
141-
SmallObject.restrictionLT (ofCocone c) (Preorder.le_refl j) ≅ F :=
141+
SmallObject.restrictionLT (ofCocone c) (le_refl j) ≅ F :=
142142
NatIso.ofComponents (fun ⟨i, hi⟩ ↦ ofCoconeObjIso c i hi)
143143
(by intros; apply ofCoconeObjIso_hom_naturality)
144144

145145
variable {c} in
146-
/-- If `c` is a colimit cocone, then so is `coconeOfLE (ofCocone c) (Preorder.le_refl j)`. -/
146+
/-- If `c` is a colimit cocone, then so is `coconeOfLE (ofCocone c) (le_refl j)`. -/
147147
def isColimitCoconeOfLEOfCocone (hc : IsColimit c) :
148-
IsColimit (coconeOfLE (ofCocone c) (Preorder.le_refl j)) :=
148+
IsColimit (coconeOfLE (ofCocone c) (le_refl j)) :=
149149
(IsColimit.precomposeInvEquiv (restrictionLTOfCoconeIso c) _).1
150150
(IsColimit.ofIsoColimit hc
151151
(Cocones.ext (ofCoconeObjIsoPt c).symm (fun ⟨i, hi⟩ ↦ by

Mathlib/MeasureTheory/Function/LpSeminorm/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ theorem eLpNorm_le_of_ae_enorm_bound {ε} [TopologicalSpace ε] [ESeminormedAddM
398398
· simp
399399
by_cases hp : p = 0
400400
· simp [hp]
401-
have : ∀ᵐ x ∂μ, ‖f x‖ₑ ≤ ‖C‖ₑ := hfC.mono fun x hx ↦ hx.trans (Preorder.le_refl C)
401+
have : ∀ᵐ x ∂μ, ‖f x‖ₑ ≤ ‖C‖ₑ := hfC.mono fun x hx ↦ hx.trans (le_refl C)
402402
refine (eLpNorm_mono_enorm_ae this).trans_eq ?_
403403
rw [eLpNorm_const _ hp (NeZero.ne μ), one_div, enorm_eq_self, smul_eq_mul]
404404

Mathlib/NumberTheory/ModularForms/EisensteinSeries/Summable.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ theorem abs_le_left_of_norm (m n : ℤ) : |n| ≤ ‖![n, m]‖ := by
4242
Matrix.cons_val_one, Matrix.cons_val_fin_one, Nat.cast_max, le_sup_iff]
4343
left
4444
rw [Int.abs_eq_natAbs]
45-
exact Preorder.le_refl _
45+
exact le_refl _
4646

4747
theorem abs_le_right_of_norm (m n : ℤ) : |m| ≤ ‖![n, m]‖ := by
4848
simp only [EisensteinSeries.norm_eq_max_natAbs, Fin.isValue, Matrix.cons_val_zero,
4949
Matrix.cons_val_one, Matrix.cons_val_fin_one, Nat.cast_max, le_sup_iff]
5050
right
5151
rw [Int.abs_eq_natAbs]
52-
exact Preorder.le_refl _
52+
exact le_refl _
5353

5454
lemma abs_norm_eq_max_natAbs (n : ℕ) : ‖![1, (n + 1 : ℤ)]‖ = n + 1 := by
5555
simp only [EisensteinSeries.norm_eq_max_natAbs, Matrix.cons_val_zero, Matrix.cons_val_one,

Mathlib/Order/Defs/LinearOrder.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ macro "compareOfLessAndEq_rfl" : tactic =>
5757
We assume that every linear ordered type has decidable `(≤)`, `(<)`, and `(=)`. -/
5858
class LinearOrder (α : Type*) extends PartialOrder α, Min α, Max α, Ord α where
5959
/-- A linear order is total. -/
60-
le_total (a b : α) : a ≤ b ∨ b ≤ a
60+
protected le_total (a b : α) : a ≤ b ∨ b ≤ a
6161
/-- In a linearly ordered type, we assume the order relations are all decidable. -/
6262
toDecidableLE : DecidableLE α
6363
/-- In a linearly ordered type, we assume the order relations are all decidable. -/
@@ -67,9 +67,9 @@ class LinearOrder (α : Type*) extends PartialOrder α, Min α, Max α, Ord α w
6767
min := fun a b => if a ≤ b then a else b
6868
max := fun a b => if a ≤ b then b else a
6969
/-- The minimum function is equivalent to the one you get from `minOfLe`. -/
70-
min_def : ∀ a b, min a b = if a ≤ b then a else b := by intros; rfl
70+
protected min_def : ∀ a b, min a b = if a ≤ b then a else b := by intros; rfl
7171
/-- The minimum function is equivalent to the one you get from `maxOfLe`. -/
72-
max_def : ∀ a b, max a b = if a ≤ b then b else a := by intros; rfl
72+
protected max_def : ∀ a b, max a b = if a ≤ b then b else a := by intros; rfl
7373
compare a b := compareOfLessAndEq a b
7474
/-- Comparison via `compare` is equal to the canonical comparison given decidable `<` and `=`. -/
7575
compare_eq_compareOfLessAndEq : ∀ a b, compare a b = compareOfLessAndEq a b := by

Mathlib/Order/Defs/PartialOrder.lean

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,10 @@ section Preorder
4343

4444
/-- A preorder is a reflexive, transitive relation `≤` with `a < b` defined in the obvious way. -/
4545
class Preorder (α : Type*) extends LE α, LT α where
46-
le_refl : ∀ a : α, a ≤ a
47-
le_trans : ∀ a b c : α, a ≤ b → b ≤ c → a ≤ c
46+
protected le_refl : ∀ a : α, a ≤ a
47+
protected le_trans : ∀ a b c : α, a ≤ b → b ≤ c → a ≤ c
4848
lt := fun a b => a ≤ b ∧ ¬b ≤ a
49-
lt_iff_le_not_ge : ∀ a b : α, a < b ↔ a ≤ b ∧ ¬b ≤ a := by intros; rfl
50-
51-
attribute [to_dual self (reorder := a c, 6 7)] Preorder.le_trans
52-
attribute [to_dual self] Preorder.lt_iff_le_not_ge
49+
protected lt_iff_le_not_ge : ∀ a b : α, a < b ↔ a ≤ b ∧ ¬b ≤ a := by intros; rfl
5350

5451
instance [Preorder α] : Std.LawfulOrderLT α where
5552
lt_iff := Preorder.lt_iff_le_not_ge
@@ -69,7 +66,10 @@ variable [Preorder α] {a b c : α}
6966
lemma le_rfl : a ≤ a := le_refl a
7067

7168
/-- The relation `≤` on a preorder is transitive. -/
72-
@[to_dual ge_trans] lemma le_trans : a ≤ b → b ≤ c → a ≤ c := Preorder.le_trans _ _ _
69+
lemma le_trans : a ≤ b → b ≤ c → a ≤ c := Preorder.le_trans _ _ _
70+
71+
@[to_dual existing le_trans]
72+
lemma ge_trans : b ≤ a → c ≤ b → c ≤ a := flip le_trans
7373

7474
@[to_dual self]
7575
lemma lt_iff_le_not_ge : a < b ↔ a ≤ b ∧ ¬b ≤ a := Preorder.lt_iff_le_not_ge _ _
@@ -176,18 +176,18 @@ section PartialOrder
176176

177177
/-- A partial order is a reflexive, transitive, antisymmetric relation `≤`. -/
178178
class PartialOrder (α : Type*) extends Preorder α where
179-
le_antisymm : ∀ a b : α, a ≤ b → b ≤ a → a = b
180-
181-
attribute [to_dual self (reorder := 5 6)] PartialOrder.le_antisymm
179+
protected le_antisymm : ∀ a b : α, a ≤ b → b ≤ a → a = b
182180

183181
instance [PartialOrder α] : Std.IsPartialOrder α where
184182
le_antisymm := PartialOrder.le_antisymm
185183

186184
variable [PartialOrder α] {a b : α}
187185

188-
@[to_dual ge_antisymm]
189186
lemma le_antisymm : a ≤ b → b ≤ a → a = b := PartialOrder.le_antisymm _ _
190187

188+
@[to_dual existing le_antisymm]
189+
lemma ge_antisymm : b ≤ a → a ≤ b → a = b := flip le_antisymm
190+
191191
@[to_dual eq_of_ge_of_le]
192192
alias eq_of_le_of_ge := le_antisymm
193193

Mathlib/Order/Max.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ theorem IsTop.isMax_iff {α} [PartialOrder α] {i j : α} (h : IsTop i) : IsMax
198198

199199
theorem IsBot.isMin_iff {α} [PartialOrder α] {i j : α} (h : IsBot i) : IsMin j ↔ j = i := by
200200
simp_rw [le_antisymm_iff, h j, and_true]
201-
exact ⟨fun a ↦ a (h j), fun a h' ↦ fun _ ↦ Preorder.le_trans j i h' a (h h')⟩
201+
exact ⟨fun a ↦ a (h j), fun a h' ↦ fun _ ↦ le_trans a (h h')⟩
202202

203203
@[simp]
204204
theorem isBot_toDual_iff : IsBot (toDual a) ↔ IsTop a :=

Mathlib/Order/RelClasses.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ end Order.Preimage
466466

467467

468468
/-- An unbundled relation class stating that `r` is the nonstrict relation corresponding to the
469-
strict relation `s`. Compare `Preorder.lt_iff_le_not_ge`. This is mostly meant to provide dot
469+
strict relation `s`. Compare `lt_iff_le_not_ge`. This is mostly meant to provide dot
470470
notation on `(⊆)` and `(⊂)`. -/
471471
class IsNonstrictStrictOrder (α : Type*) (r : semiOutParam (α → α → Prop)) (s : α → α → Prop) :
472472
Prop where

0 commit comments

Comments
 (0)