Skip to content

Commit f629ab0

Browse files
committed
chore(Order/Shrink): use to_dual (#34190)
1 parent b55a1a2 commit f629ab0

File tree

2 files changed

+15
-33
lines changed

2 files changed

+15
-33
lines changed

Mathlib/Order/Shrink.lean

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ universe u v
2222

2323
variable (α : Type v) [Small.{u} α]
2424

25-
instance [Preorder α] : Preorder (Shrink.{u} α) where
26-
le a b := (equivShrink α).symm a ≤ (equivShrink _).symm b
27-
le_refl a := le_refl _
28-
le_trans _ _ _ h₁ h₂ := h₁.trans h₂
25+
instance [Preorder α] : Preorder (Shrink.{u} α) :=
26+
Preorder.lift (equivShrink α).symm
2927

3028
/-- The order isomorphism `α ≃o Shrink.{u} α`. -/
3129
noncomputable def orderIsoShrink [Preorder α] : α ≃o Shrink.{u} α where
@@ -53,51 +51,34 @@ noncomputable instance [LinearOrder α] : LinearOrder (Shrink.{u} α) where
5351
le_total _ _ := le_total _ _
5452
toDecidableLE _ _ := LinearOrder.toDecidableLE _ _
5553

54+
@[to_dual]
5655
noncomputable instance [Bot α] : Bot (Shrink.{u} α) where
5756
bot := equivShrink _ ⊥
5857

59-
@[simp]
58+
@[to_dual (attr := simp)]
6059
lemma equivShrink_bot [Bot α] : equivShrink.{u} α ⊥ = ⊥ := rfl
6160

62-
@[simp]
61+
@[to_dual (attr := simp)]
6362
lemma equivShrink_symm_bot [Bot α] : (equivShrink.{u} α).symm ⊥ = ⊥ :=
6463
(equivShrink.{u} α).injective (by simp)
6564

66-
noncomputable instance [Top α] : Top (Shrink.{u} α) where
67-
top := equivShrink _ ⊤
68-
69-
@[simp]
70-
lemma equivShrink_top [Top α] : equivShrink.{u} α ⊤ = ⊤ := rfl
71-
72-
@[simp]
73-
lemma equivShrink_symm_top [Top α] : (equivShrink.{u} α).symm ⊤ = ⊤ :=
74-
(equivShrink.{u} α).injective (by simp)
75-
7665
section Preorder
7766

7867
variable [Preorder α]
7968

80-
noncomputable instance [OrderBot α] :
81-
OrderBot (Shrink.{u} α) where
82-
bot_le a := by
83-
simp only [← (orderIsoShrink.{u} α).symm.le_iff_le,
84-
orderIsoShrink_symm_apply, equivShrink_symm_bot, bot_le]
85-
86-
noncomputable instance [OrderTop α] :
87-
OrderTop (Shrink.{u} α) where
88-
le_top a := by
89-
simp only [← (orderIsoShrink.{u} α).symm.le_iff_le,
90-
orderIsoShrink_symm_apply, equivShrink_symm_top, le_top]
69+
@[to_dual]
70+
noncomputable instance [OrderBot α] : OrderBot (Shrink.{u} α) where
71+
bot_le a := by simp [← (orderIsoShrink.{u} α).symm.le_iff_le]
9172

92-
noncomputable instance [SuccOrder α] :
93-
SuccOrder (Shrink.{u} α) :=
73+
@[to_dual]
74+
noncomputable instance [SuccOrder α] : SuccOrder (Shrink.{u} α) :=
9475
SuccOrder.ofOrderIso (orderIsoShrink.{u} α)
9576

96-
noncomputable instance [PredOrder α] :
97-
PredOrder (Shrink.{u} α) :=
98-
PredOrder.ofOrderIso (orderIsoShrink.{u} α)
99-
10077
instance [WellFoundedLT α] : WellFoundedLT (Shrink.{u} α) where
10178
wf := (orderIsoShrink.{u} α).symm.toRelIsoLT.toRelEmbedding.isWellFounded.wf
10279

80+
@[to_dual existing]
81+
instance [WellFoundedGT α] : WellFoundedGT (Shrink.{u} α) where
82+
wf := (orderIsoShrink.{u} α).symm.dual.toRelIsoLT.toRelEmbedding.isWellFounded.wf
83+
10384
end Preorder

Mathlib/Order/SuccPred/Basic.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,7 @@ protected abbrev SuccOrder.ofOrderIso [SuccOrder X] (f : X ≃o Y) : SuccOrder Y
11311131

11321132
-- See note [reducible non-instances]
11331133
/-- `PredOrder` transfers across equivalences between orders. -/
1134+
@[to_dual existing]
11341135
protected abbrev PredOrder.ofOrderIso [PredOrder X] (f : X ≃o Y) :
11351136
PredOrder Y where
11361137
pred y := f (pred (f.symm y))

0 commit comments

Comments
 (0)