@@ -154,6 +154,7 @@ class order_bot (α : Type u) [has_le α] extends has_bot α :=
154
154
(bot_le : ∀ a : α, ⊥ ≤ a)
155
155
156
156
section order_bot
157
+
157
158
section has_le
158
159
variables [has_le α] [order_bot α] {a : α}
159
160
@@ -162,6 +163,27 @@ variables [has_le α] [order_bot α] {a : α}
162
163
163
164
end has_le
164
165
166
+ namespace order_dual
167
+ variable (α)
168
+
169
+ instance [has_bot α] : has_top αᵒᵈ := ⟨(⊥ : α)⟩
170
+ instance [has_top α] : has_bot αᵒᵈ := ⟨(⊤ : α)⟩
171
+
172
+ instance [has_le α] [order_bot α] : order_top αᵒᵈ :=
173
+ { le_top := @bot_le α _ _,
174
+ .. order_dual.has_top α }
175
+
176
+ instance [has_le α] [order_top α] : order_bot αᵒᵈ :=
177
+ { bot_le := @le_top α _ _,
178
+ .. order_dual.has_bot α }
179
+
180
+ @[simp] lemma of_dual_bot [has_top α] : of_dual ⊥ = (⊤ : α) := rfl
181
+ @[simp] lemma of_dual_top [has_bot α] : of_dual ⊤ = (⊥ : α) := rfl
182
+ @[simp] lemma to_dual_bot [has_bot α] : to_dual (⊥ : α) = ⊤ := rfl
183
+ @[simp] lemma to_dual_top [has_top α] : to_dual (⊤ : α) = ⊥ := rfl
184
+
185
+ end order_dual
186
+
165
187
section preorder
166
188
variables [preorder α] [order_bot α] {a b : α}
167
189
@@ -201,15 +223,14 @@ lemma ne.bot_lt' (h : ⊥ ≠ a) : ⊥ < a := h.symm.bot_lt
201
223
lemma ne_bot_of_le_ne_bot (hb : b ≠ ⊥) (hab : b ≤ a) : a ≠ ⊥ := (hb.bot_lt.trans_le hab).ne'
202
224
203
225
lemma strict_mono.apply_eq_bot_iff (hf : strict_mono f) : f a = f ⊥ ↔ a = ⊥ :=
204
- ⟨λ h, not_bot_lt_iff. 1 $ λ ha, (hf ha).ne' h, congr_arg _⟩
226
+ hf.dual.apply_eq_top_iff
205
227
206
228
lemma strict_anti.apply_eq_bot_iff (hf : strict_anti f) : f a = f ⊥ ↔ a = ⊥ :=
207
- ⟨λ h, not_bot_lt_iff. 1 $ λ ha, (hf ha).ne h, congr_arg _⟩
229
+ hf.dual.apply_eq_top_iff
208
230
209
231
variables [nontrivial α]
210
232
211
- lemma not_is_max_bot : ¬ is_max (⊥ : α) :=
212
- λ h, let ⟨a, ha⟩ := exists_ne (⊥ : α) in ha $ le_bot_iff.1 $ h bot_le
233
+ lemma not_is_max_bot : ¬ is_max (⊥ : α) := @not_is_min_top αᵒᵈ _ _ _
213
234
214
235
end order_bot
215
236
@@ -267,7 +288,7 @@ inf_of_le_right le_top
267
288
inf_of_le_left le_top
268
289
269
290
@[simp] theorem inf_eq_top_iff : a ⊓ b = ⊤ ↔ (a = ⊤ ∧ b = ⊤) :=
270
- by rw [eq_top_iff, le_inf_iff]; simp
291
+ @sup_eq_bot_iff αᵒᵈ _ _ _ _
271
292
272
293
end semilattice_inf_top
273
294
@@ -289,6 +310,9 @@ end semilattice_inf_bot
289
310
@[ancestor order_top order_bot]
290
311
class bounded_order (α : Type u) [has_le α] extends order_top α, order_bot α.
291
312
313
+ instance (α : Type u) [has_le α] [bounded_order α] : bounded_order αᵒᵈ :=
314
+ { .. order_dual.order_top α, .. order_dual.order_bot α }
315
+
292
316
theorem bounded_order.ext {α} [partial_order α] {A B : bounded_order α} : A = B :=
293
317
begin
294
318
have ht : @bounded_order.to_order_top α _ A = @bounded_order.to_order_top α _ B := order_top.ext,
@@ -821,7 +845,7 @@ def untop : Π (x : with_top α), x ≠ ⊤ → α :=
821
845
with_bot.unbot
822
846
823
847
@[simp] lemma coe_untop (x : with_top α) (h : x ≠ ⊤) : (x.untop h : with_top α) = x :=
824
- by { cases x, simpa using h, refl, }
848
+ with_bot.coe_unbot x h
825
849
826
850
@[simp] lemma untop_coe (x : α) (h : (x : with_top α) ≠ ⊤ := coe_ne_top) :
827
851
(x : with_top α).untop h = x := rfl
@@ -852,8 +876,7 @@ instance [order_bot α] : order_bot (with_top α) :=
852
876
instance [order_bot α] : bounded_order (with_top α) :=
853
877
{ ..with_top.order_top, ..with_top.order_bot }
854
878
855
- lemma not_top_le_coe (a : α) : ¬ (⊤ : with_top α) ≤ ↑a :=
856
- λ h, let ⟨b, hb, _⟩ := h _ rfl in option.not_mem_none _ hb
879
+ lemma not_top_le_coe (a : α) : ¬ (⊤ : with_top α) ≤ ↑a := with_bot.not_coe_le_bot (to_dual a)
857
880
858
881
lemma le_coe : ∀ {o : option α}, a ∈ o → (@has_le.le (with_top α) _ o b ↔ a ≤ b) | _ rfl :=
859
882
coe_le_coe
@@ -966,11 +989,7 @@ instance decidable_lt [has_lt α] [@decidable_rel α (<)] : @decidable_rel (with
966
989
λ x y, @with_bot.decidable_lt αᵒᵈ _ _ y x
967
990
968
991
instance is_total_le [has_le α] [is_total α (≤)] : is_total (with_top α) (≤) :=
969
- ⟨λ a b, match a, b with
970
- | _ , none := or.inl le_top
971
- | none , _ := or.inr le_top
972
- | some x, some y := (total_of (≤) x y).imp some_le_some.2 some_le_some.2
973
- end ⟩
992
+ @order_dual.is_total_le (with_bot αᵒᵈ) _ _
974
993
975
994
instance [linear_order α] : linear_order (with_top α) := lattice.to_linear_order _
976
995
@@ -998,36 +1017,18 @@ lemma _root_.with_bot.well_founded_gt [preorder α] (h : @well_founded α (>)) :
998
1017
@with_top.well_founded_lt αᵒᵈ _ h
999
1018
1000
1019
instance [has_lt α] [densely_ordered α] [no_max_order α] : densely_ordered (with_top α) :=
1001
- ⟨ λ a b,
1002
- match a, b with
1003
- | none, a := λ h : ⊤ < a, (not_none_lt _ h).elim
1004
- | some a, none := λ h, let ⟨b, hb⟩ := exists_gt a in ⟨b, coe_lt_coe.2 hb, coe_lt_top b⟩
1005
- | some a, some b := λ h, let ⟨a, ha₁, ha₂⟩ := exists_between (coe_lt_coe.1 h) in
1006
- ⟨a, coe_lt_coe.2 ha₁, coe_lt_coe.2 ha₂⟩
1007
- end ⟩
1020
+ order_dual.densely_ordered (with_bot αᵒᵈ)
1008
1021
1009
1022
lemma lt_iff_exists_coe_btwn [preorder α] [densely_ordered α] [no_max_order α] {a b : with_top α} :
1010
1023
a < b ↔ ∃ x : α, a < ↑x ∧ ↑x < b :=
1011
1024
⟨λ h, let ⟨y, hy⟩ := exists_between h, ⟨x, hx⟩ := lt_iff_exists_coe.1 hy.2 in ⟨x, hx.1 ▸ hy⟩,
1012
1025
λ ⟨x, hx⟩, lt_trans hx.1 hx.2 ⟩
1013
1026
1014
1027
instance [has_le α] [no_bot_order α] [nonempty α] : no_bot_order (with_top α) :=
1015
- ⟨begin
1016
- apply with_top.rec_top_coe,
1017
- { exact ‹nonempty α›.elim (λ a, ⟨a, not_top_le_coe a⟩) },
1018
- { intro a,
1019
- obtain ⟨b, h⟩ := exists_not_ge a,
1020
- exact ⟨b, by rwa coe_le_coe⟩ }
1021
- end ⟩
1028
+ order_dual.no_bot_order (with_bot αᵒᵈ)
1022
1029
1023
1030
instance [has_lt α] [no_min_order α] [nonempty α] : no_min_order (with_top α) :=
1024
- ⟨begin
1025
- apply rec_top_coe,
1026
- { exact ‹nonempty α›.elim (λ a, ⟨a, with_top.coe_lt_top a⟩) },
1027
- { intro a,
1028
- obtain ⟨b, ha⟩ := exists_lt a,
1029
- exact ⟨b, coe_lt_coe.mpr ha⟩ }
1030
- end ⟩
1031
+ order_dual.no_min_order (with_bot αᵒᵈ)
1031
1032
1032
1033
end with_top
1033
1034
@@ -1107,32 +1108,6 @@ by rw [←coe_top htop, ext_iff]
1107
1108
1108
1109
end subtype
1109
1110
1110
- section order_dual
1111
- variable (α)
1112
-
1113
- instance [has_bot α] : has_top αᵒᵈ := ⟨(⊥ : α)⟩
1114
- instance [has_top α] : has_bot αᵒᵈ := ⟨(⊤ : α)⟩
1115
-
1116
- instance [has_le α] [order_bot α] : order_top αᵒᵈ :=
1117
- { le_top := @bot_le α _ _,
1118
- .. order_dual.has_top α }
1119
-
1120
- instance [has_le α] [order_top α] : order_bot αᵒᵈ :=
1121
- { bot_le := @le_top α _ _,
1122
- .. order_dual.has_bot α }
1123
-
1124
- instance [has_le α] [bounded_order α] : bounded_order αᵒᵈ :=
1125
- { .. order_dual.order_top α, .. order_dual.order_bot α }
1126
-
1127
- open order_dual
1128
-
1129
- @[simp] lemma of_dual_bot [has_top α] : of_dual ⊥ = (⊤ : α) := rfl
1130
- @[simp] lemma of_dual_top [has_bot α] : of_dual ⊤ = (⊥ : α) := rfl
1131
- @[simp] lemma to_dual_bot [has_bot α] : to_dual (⊥ : α) = ⊤ := rfl
1132
- @[simp] lemma to_dual_top [has_top α] : to_dual (⊤ : α) = ⊥ := rfl
1133
-
1134
- end order_dual
1135
-
1136
1111
namespace prod
1137
1112
variables (α β)
1138
1113
0 commit comments