@@ -19,38 +19,44 @@ This module provides typeclass instances and lemmas about order-related typeclas
1919
2020section AxiomaticInstances
2121
22- public theorem not_refl_iff_irrefl : Refl (¬ r · ·) ↔ Irrefl r :=
23- ⟨fun ⟨h⟩ => ⟨h⟩, fun ⟨h⟩ => ⟨h⟩⟩
22+ public instance (r : α → α → Prop ) [Asymm r] : Irrefl r where
23+ irrefl a h := Asymm.asymm a a h h
2424
25- public theorem not_irrefl_iff_refl : Irrefl (¬ r · ·) ↔ Refl r :=
26- ⟨fun ⟨h⟩ => ⟨ by simpa using h⟩, fun ⟨h⟩ => ⟨ by simpa using h⟩⟩
25+ public instance (r : α → α → Prop ) [Total r] : Refl r where
26+ refl a := by simpa using Total.total a a
2727
28- public theorem Refl.irrefl_of_refl_not {α : Type u} { r : α → α → Prop } [i : Refl (¬ r · ·)] :
29- Irrefl r := not_refl_iff_irrefl.mp i
28+ public instance ( r : α → α → Prop ) [Asymm r] : Antisymm r where
29+ antisymm a b h h' := (Asymm.asymm a b h h').elim
3030
31- public theorem Irrefl.refl_of_irrefl_not {α : Type u} { r : α → α → Prop }
32- [i : Irrefl (¬ r · ·)] : Refl r := not_irrefl_iff_refl.mp i
31+ public instance ( r : α → α → Prop ) [Total r] : Tricho r where
32+ tricho a b h h' := by simpa [h, h'] using Total.total ( r := r) a b
3333
34- public instance (r : α → α → Prop ) [Asymm r] : Irrefl r where
35- irrefl a h := Asymm.asymm a a h h
34+ public theorem Tricho.rel_or_eq_or_swap {r : α → α → Prop } [Tricho r] {a b} :
35+ r a b ∨ a = b ∨ r b a := by
36+ cases Classical.em (r a b) with | inl hab | inr hab
37+ · exact Or.inl hab
38+ · cases Classical.em (r b a) with | inl hba | inr hba
39+ · exact Or.inr (Or.inr hba)
40+ · exact Or.inr (Or.inl (Tricho.tricho _ _ hab hba))
3641
37- public instance (r : α → α → Prop ) [Asymm r] : Antisymm r where
38- antisymm a b h h' := by simpa using Asymm.asymm a b h h'
42+ public theorem tricho_of_rel_or_eq_or_swap {r : α → α → Prop }
43+ (h : ∀ {a b}, r a b ∨ a = b ∨ r b a) : Tricho r where
44+ tricho _ _ hab hba := (h.resolve_left hab).resolve_right hba
3945
40- public instance {r : α → α → Prop } [Total r] : Refl r where
41- refl a := (Total.total a a ).elim (· ) (·)
46+ public theorem Total.of_not_swap {r : α → α → Prop } [Total r] {a b} (h : ¬ r a b) : r b a :=
47+ (Total.total a b ).elim (fun h' => (h h').elim ) (·)
4248
43- public instance {r : α → α → Prop } [Total r] : Tricho r where
44- tricho a b h h' := by simpa [h, h'] using Total.total (r := r) a b
49+ public def total_of_of_not_swap {r : α → α → Prop } (h : ∀ {a b}, ¬ r a b → r b a) : Total r where
50+ total a b := Classical.byCases (p := r a b) Or.inl (fun hab => Or.inr (h hab))
4551
46- public instance Antisymm.tricho_of_antisymm_not {r : α → α → Prop } [i : Antisymm (¬ r · ·)] :
47- Tricho r where tricho a b h h' := i.antisymm a b h h'
52+ public def total_of_refl_of_tricho (r : α → α → Prop ) [Refl r] [Tricho r] : Total r where
53+ total a b := (Tricho.rel_or_eq_or_swap (a := a) (b := b) (r := r)).elim Or.inl <|
54+ fun h => h.elim (fun h => h ▸ Or.inl (Refl.refl _)) Or.inr
4855
49- public instance Tricho.antisymm_of_tricho_not {r : α → α → Prop } [i : Tricho (¬ r · ·)] :
50- Antisymm r where
51- antisymm a b h h' := i.tricho a b (· h) (· h')
56+ public def asymm_of_irrefl_of_antisymm (r : α → α → Prop ) [Irrefl r] [Antisymm r] : Asymm r where
57+ asymm a b h h' := Irrefl.irrefl _ (Antisymm.antisymm a b h h' ▸ h)
5258
53- public instance Total.asymm_of_total_not {r : α → α → Prop } [i : Total (¬ r · ·)] : Asymm r where
59+ public def Total.asymm_of_total_not {r : α → α → Prop } [i : Total (¬ r · ·)] : Asymm r where
5460 asymm a b h := by cases i.total a b <;> trivial
5561
5662public theorem Asymm.total_not {r : α → α → Prop } [i : Asymm r] : Total (¬ r · ·) where
@@ -59,9 +65,6 @@ public theorem Asymm.total_not {r : α → α → Prop} [i : Asymm r] : Total (
5965 · exact Or.inr <| i.asymm a b hab
6066 · exact Or.inl hab
6167
62- public instance Asymm.total_of_asymm_not {r : α → α → Prop } [i : Asymm (¬ r · ·)] : Total r where
63- total a b := by simpa using (Asymm.total_not (i := i)).total a b
64-
6568public instance {α : Type u} [LE α] [IsPartialOrder α] :
6669 Antisymm (α := α) (· ≤ ·) where
6770 antisymm := IsPartialOrder.le_antisymm
@@ -102,9 +105,7 @@ public theorem le_total {α : Type u} [LE α] [Std.Total (α := α) (· ≤ ·)]
102105 Std.Total.total a b
103106
104107public theorem le_of_not_ge {α : Type u} [LE α] [Std.Total (α := α) (· ≤ ·)] {a b : α} :
105- ¬ b ≤ a → a ≤ b := by
106- intro h
107- simpa [h] using Std.Total.total a b (r := (· ≤ ·))
108+ ¬ b ≤ a → a ≤ b := Total.of_not_swap
108109
109110end LE
110111
@@ -118,18 +119,30 @@ public theorem lt_iff_le_and_not_ge {α : Type u} [LT α] [LE α] [LawfulOrderLT
118119 a < b ↔ a ≤ b ∧ ¬ b ≤ a :=
119120 LawfulOrderLT.lt_iff a b
120121
121- public theorem not_lt {α : Type u} [LT α] [LE α] [Std.Total (α := α) (· ≤ ·)] [LawfulOrderLT α]
122- {a b : α} : ¬ a < b ↔ b ≤ a := by
123- simp [lt_iff_le_and_not_ge, Classical.not_not, Std.Total.total]
122+ public theorem not_lt_iff_not_le_or_ge {α : Type u} [LT α] [LE α] [LawfulOrderLT α]
123+ {a b : α} : ¬ a < b ↔ ¬ a ≤ b ∨ b ≤ a := by
124+ simp only [lt_iff_le_and_not_ge, Classical.not_and_iff_not_or_not, Classical.not_not]
125+
126+ public theorem not_le_of_gt {α : Type u} [LT α] [LE α] [LawfulOrderLT α] {a b : α}
127+ (h : a < b) : ¬ b ≤ a := (lt_iff_le_and_not_ge.1 h).2
128+
129+ public theorem not_lt_of_ge {α : Type u} [LT α] [LE α] [LawfulOrderLT α] {a b : α}
130+ (h : a ≤ b) : ¬ b < a := imp_not_comm.1 not_le_of_gt h
131+
132+ public instance {α : Type u} {_ : LE α} [LT α] [LawfulOrderLT α]
133+ [Tricho (α := α) (· < ·)] : Antisymm (α := α) (· ≤ ·) where
134+ antisymm _ _ hab hba := Tricho.tricho _ _ (not_lt_of_ge hba) (not_lt_of_ge hab)
124135
125136public theorem not_gt_of_lt {α : Type u} [LT α] [i : Std.Asymm (α := α) (· < ·)] {a b : α}
126137 (h : a < b) : ¬ b < a :=
127138 i.asymm a b h
128139
129140public theorem le_of_lt {α : Type u} [LT α] [LE α] [LawfulOrderLT α] {a b : α} (h : a < b) :
130- a ≤ b := by
131- simp only [LawfulOrderLT.lt_iff] at h
132- exact h.1
141+ a ≤ b := (lt_iff_le_and_not_ge.1 h).1
142+
143+ public instance {α : Type u} {_ : LT α} [LE α] [LawfulOrderLT α]
144+ [Antisymm (α := α) (· ≤ ·)] : Antisymm (α := α) (· < ·) where
145+ antisymm _ _ hab hba := Antisymm.antisymm _ _ (le_of_lt hab) (le_of_lt hba)
133146
134147public instance {α : Type u} [LT α] [LE α] [LawfulOrderLT α] :
135148 Std.Asymm (α := α) (· < ·) where
@@ -138,8 +151,9 @@ public instance {α : Type u} [LT α] [LE α] [LawfulOrderLT α] :
138151 intro h h'
139152 exact h.2 .elim h'.1
140153
141- public instance {α : Type u} [LT α] [LE α] [LawfulOrderLT α] :
142- Std.Irrefl (α := α) (· < ·) := inferInstance
154+ @[deprecated Asymm.total_not (since := " 2025-10-24" )]
155+ public def instIrreflLtOfIsPreorderOfLawfulOrderLT {α : Type u} [LT α] [LE α] [IsPreorder α]
156+ [LawfulOrderLT α] : Std.Irrefl (α := α) (· < ·) := inferInstance
143157
144158public instance {α : Type u} [LT α] [LE α] [Trans (α := α) (· ≤ ·) (· ≤ ·) (· ≤ ·) ]
145159 [LawfulOrderLT α] : Trans (α := α) (· < ·) (· < ·) (· < ·) where
@@ -150,10 +164,19 @@ public instance {α : Type u} [LT α] [LE α] [Trans (α := α) (· ≤ ·) (·
150164 · intro hca
151165 exact hab.2 .elim (le_trans hbc.1 hca)
152166
167+ public theorem not_lt {α : Type u} [LT α] [LE α] [Std.Total (α := α) (· ≤ ·)] [LawfulOrderLT α]
168+ {a b : α} : ¬ a < b ↔ b ≤ a := by
169+ simp [not_lt_iff_not_le_or_ge]
170+ exact le_of_not_ge
171+
172+ public theorem not_le {α : Type u} [LT α] [LE α] [Std.Total (α := α) (· ≤ ·)] [LawfulOrderLT α]
173+ {a b : α} : ¬ a ≤ b ↔ b < a := by
174+ simp [lt_iff_le_and_not_ge]
175+ exact le_of_not_ge
176+
153177public instance {α : Type u} {_ : LT α} [LE α] [LawfulOrderLT α]
154- [Total (α := α) (· ≤ ·)] [Antisymm (α := α) (· ≤ ·)] :
155- Antisymm (α := α) (¬ · < ·) where
156- antisymm a b hab hba := by
178+ [Total (α := α) (· ≤ ·)] [Antisymm (α := α) (· ≤ ·)] : Tricho (α := α) (· < ·) where
179+ tricho a b hab hba := by
157180 simp only [not_lt] at hab hba
158181 exact Antisymm.antisymm (r := (· ≤ ·)) a b hba hab
159182
@@ -164,9 +187,9 @@ public instance {α : Type u} {_ : LT α} [LE α] [LawfulOrderLT α]
164187 simp only [not_lt] at hab hbc ⊢
165188 exact le_trans hbc hab
166189
167- public instance {α : Type u} {_ : LT α} [LE α] [LawfulOrderLT α] [Total (α := α) (· ≤ ·)] :
168- Total (α := α) (¬ · < ·) where
169- total a b := by simp [not_lt, Std.Total.total]
190+ @[deprecated Asymm.total_not (since := " 2025-10-24 " )]
191+ public def instTotalNotLtOfLawfulOrderLTOfLe {α : Type u} {_ : LT α} [LE α] [LawfulOrderLT α]
192+ : Total (α := α) (¬ · < ·) := Asymm.total_not
170193
171194public theorem lt_of_le_of_lt {α : Type u} [LE α] [LT α]
172195 [Trans (α := α) (· ≤ ·) (· ≤ ·) (· ≤ ·)] [LawfulOrderLT α] {a b c : α} (hab : a ≤ b)
0 commit comments