@@ -35,132 +35,83 @@ section LE
3535
3636variable [LE α] {s t : Set α} {a : α}
3737
38+ @[to_dual]
3839theorem isUpperSet_empty : IsUpperSet (∅ : Set α) := fun _ _ _ => id
3940
40- theorem isLowerSet_empty : IsLowerSet (∅ : Set α) := fun _ _ _ => id
41-
41+ @[to_dual]
4242theorem isUpperSet_univ : IsUpperSet (univ : Set α) := fun _ _ _ => id
4343
44- theorem isLowerSet_univ : IsLowerSet (univ : Set α) := fun _ _ _ => id
45-
44+ @[to_dual]
4645theorem IsUpperSet.compl (hs : IsUpperSet s) : IsLowerSet sᶜ := fun _a _b h hb ha => hb <| hs h ha
4746
48- theorem IsLowerSet.compl (hs : IsLowerSet s) : IsUpperSet sᶜ := fun _a _b h hb ha => hb <| hs h ha
49-
50- @[simp]
47+ @ [to_dual (attr := simp)]
5148theorem isUpperSet_compl : IsUpperSet sᶜ ↔ IsLowerSet s :=
5249 ⟨fun h => by
5350 convert h.compl
5451 rw [compl_compl], IsLowerSet.compl⟩
5552
56- @[simp]
57- theorem isLowerSet_compl : IsLowerSet sᶜ ↔ IsUpperSet s :=
58- ⟨fun h => by
59- convert h.compl
60- rw [compl_compl], IsUpperSet.compl⟩
61-
53+ @[to_dual]
6254theorem IsUpperSet.union (hs : IsUpperSet s) (ht : IsUpperSet t) : IsUpperSet (s ∪ t) :=
6355 fun _ _ h => Or.imp (hs h) (ht h)
6456
65- theorem IsLowerSet.union (hs : IsLowerSet s) (ht : IsLowerSet t) : IsLowerSet (s ∪ t) :=
66- fun _ _ h => Or.imp (hs h) (ht h)
67-
57+ @[to_dual]
6858theorem IsUpperSet.inter (hs : IsUpperSet s) (ht : IsUpperSet t) : IsUpperSet (s ∩ t) :=
6959 fun _ _ h => And.imp (hs h) (ht h)
7060
71- theorem IsLowerSet.inter (hs : IsLowerSet s) (ht : IsLowerSet t) : IsLowerSet (s ∩ t) :=
72- fun _ _ h => And.imp (hs h) (ht h)
73-
61+ @[to_dual]
7462theorem isUpperSet_sUnion {S : Set (Set α)} (hf : ∀ s ∈ S, IsUpperSet s) : IsUpperSet (⋃₀ S) :=
7563 fun _ _ h => Exists.imp fun _ hs => ⟨hs.1 , hf _ hs.1 h hs.2 ⟩
7664
77- theorem isLowerSet_sUnion {S : Set (Set α)} (hf : ∀ s ∈ S, IsLowerSet s) : IsLowerSet (⋃₀ S) :=
78- fun _ _ h => Exists.imp fun _ hs => ⟨hs.1 , hf _ hs.1 h hs.2 ⟩
79-
65+ @[to_dual]
8066theorem isUpperSet_iUnion {f : ι → Set α} (hf : ∀ i, IsUpperSet (f i)) : IsUpperSet (⋃ i, f i) :=
8167 isUpperSet_sUnion <| forall_mem_range.2 hf
8268
83- theorem isLowerSet_iUnion {f : ι → Set α} (hf : ∀ i, IsLowerSet (f i)) : IsLowerSet (⋃ i, f i) :=
84- isLowerSet_sUnion <| forall_mem_range.2 hf
85-
69+ @[to_dual]
8670theorem isUpperSet_iUnion₂ {f : ∀ i, κ i → Set α} (hf : ∀ i j, IsUpperSet (f i j)) :
8771 IsUpperSet (⋃ (i) (j), f i j) :=
8872 isUpperSet_iUnion fun i => isUpperSet_iUnion <| hf i
8973
90- theorem isLowerSet_iUnion₂ {f : ∀ i, κ i → Set α} (hf : ∀ i j, IsLowerSet (f i j)) :
91- IsLowerSet (⋃ (i) (j), f i j) :=
92- isLowerSet_iUnion fun i => isLowerSet_iUnion <| hf i
93-
74+ @[to_dual]
9475theorem isUpperSet_sInter {S : Set (Set α)} (hf : ∀ s ∈ S, IsUpperSet s) : IsUpperSet (⋂₀ S) :=
9576 fun _ _ h => forall ₂_imp fun s hs => hf s hs h
9677
97- theorem isLowerSet_sInter {S : Set (Set α)} (hf : ∀ s ∈ S, IsLowerSet s) : IsLowerSet (⋂₀ S) :=
98- fun _ _ h => forall ₂_imp fun s hs => hf s hs h
99-
78+ @[to_dual]
10079theorem isUpperSet_iInter {f : ι → Set α} (hf : ∀ i, IsUpperSet (f i)) : IsUpperSet (⋂ i, f i) :=
10180 isUpperSet_sInter <| forall_mem_range.2 hf
10281
103- theorem isLowerSet_iInter {f : ι → Set α} (hf : ∀ i, IsLowerSet (f i)) : IsLowerSet (⋂ i, f i) :=
104- isLowerSet_sInter <| forall_mem_range.2 hf
105-
82+ @[to_dual]
10683theorem isUpperSet_iInter₂ {f : ∀ i, κ i → Set α} (hf : ∀ i j, IsUpperSet (f i j)) :
10784 IsUpperSet (⋂ (i) (j), f i j) :=
10885 isUpperSet_iInter fun i => isUpperSet_iInter <| hf i
10986
110- theorem isLowerSet_iInter₂ {f : ∀ i, κ i → Set α} (hf : ∀ i j, IsLowerSet (f i j)) :
111- IsLowerSet (⋂ (i) (j), f i j) :=
112- isLowerSet_iInter fun i => isLowerSet_iInter <| hf i
113-
114- @[simp]
115- theorem isLowerSet_preimage_ofDual_iff : IsLowerSet (ofDual ⁻¹' s) ↔ IsUpperSet s :=
116- Iff.rfl
117-
118- @[simp]
87+ @ [to_dual (attr := simp)]
11988theorem isUpperSet_preimage_ofDual_iff : IsUpperSet (ofDual ⁻¹' s) ↔ IsLowerSet s :=
12089 Iff.rfl
12190
122- @[simp]
123- theorem isLowerSet_preimage_toDual_iff {s : Set αᵒᵈ} : IsLowerSet (toDual ⁻¹' s) ↔ IsUpperSet s :=
124- Iff.rfl
125-
126- @[simp]
91+ @ [to_dual (attr := simp)]
12792theorem isUpperSet_preimage_toDual_iff {s : Set αᵒᵈ} : IsUpperSet (toDual ⁻¹' s) ↔ IsLowerSet s :=
12893 Iff.rfl
12994
130- alias ⟨_, IsUpperSet.toDual⟩ := isLowerSet_preimage_ofDual_iff
131-
132- alias ⟨_, IsLowerSet.toDual⟩ := isUpperSet_preimage_ofDual_iff
133-
134- alias ⟨_, IsUpperSet.ofDual⟩ := isLowerSet_preimage_toDual_iff
135-
136- alias ⟨_, IsLowerSet.ofDual⟩ := isUpperSet_preimage_toDual_iff
95+ @[to_dual] alias ⟨_, IsUpperSet.toDual⟩ := isLowerSet_preimage_ofDual_iff
96+ @[to_dual] alias ⟨_, IsUpperSet.ofDual⟩ := isLowerSet_preimage_toDual_iff
13797
98+ @[to_dual]
13899lemma IsUpperSet.isLowerSet_preimage_coe (hs : IsUpperSet s) :
139100 IsLowerSet ((↑) ⁻¹' t : Set s) ↔ ∀ b ∈ s, ∀ c ∈ t, b ≤ c → b ∈ t := by aesop
140101
141- lemma IsLowerSet.isUpperSet_preimage_coe (hs : IsLowerSet s) :
142- IsUpperSet ((↑) ⁻¹' t : Set s) ↔ ∀ b ∈ s, ∀ c ∈ t, c ≤ b → b ∈ t := by aesop
143-
102+ @[to_dual]
144103lemma IsUpperSet.sdiff (hs : IsUpperSet s) (ht : ∀ b ∈ s, ∀ c ∈ t, b ≤ c → b ∈ t) :
145104 IsUpperSet (s \ t) :=
146105 fun _b _c hbc hb ↦ ⟨hs hbc hb.1 , fun hc ↦ hb.2 <| ht _ hb.1 _ hc hbc⟩
147106
148- lemma IsLowerSet.sdiff (hs : IsLowerSet s) (ht : ∀ b ∈ s, ∀ c ∈ t, c ≤ b → b ∈ t) :
149- IsLowerSet (s \ t) :=
150- fun _b _c hcb hb ↦ ⟨hs hcb hb.1 , fun hc ↦ hb.2 <| ht _ hb.1 _ hc hcb⟩
151-
107+ @[to_dual]
152108lemma IsUpperSet.sdiff_of_isLowerSet (hs : IsUpperSet s) (ht : IsLowerSet t) : IsUpperSet (s \ t) :=
153109 hs.sdiff <| by aesop
154110
155- lemma IsLowerSet.sdiff_of_isUpperSet (hs : IsLowerSet s) (ht : IsUpperSet t) : IsLowerSet (s \ t) :=
156- hs.sdiff <| by aesop
157-
111+ @[to_dual]
158112lemma IsUpperSet.erase (hs : IsUpperSet s) (has : ∀ b ∈ s, b ≤ a → b = a) : IsUpperSet (s \ {a}) :=
159113 hs.sdiff <| by simpa using has
160114
161- lemma IsLowerSet.erase (hs : IsLowerSet s) (has : ∀ b ∈ s, a ≤ b → b = a) : IsLowerSet (s \ {a}) :=
162- hs.sdiff <| by simpa using has
163-
164115end LE
165116
166117section Preorder
@@ -203,16 +154,12 @@ theorem IsUpperSet.preimage (hs : IsUpperSet s) {f : β → α} (hf : Monotone f
203154theorem IsLowerSet.preimage (hs : IsLowerSet s) {f : β → α} (hf : Monotone f) :
204155 IsLowerSet (f ⁻¹' s : Set β) := fun _ _ h => hs <| hf h
205156
157+ @[to_dual]
206158theorem IsUpperSet.image (hs : IsUpperSet s) (f : α ≃o β) : IsUpperSet (f '' s : Set β) := by
207159 change IsUpperSet ((f : α ≃ β) '' s)
208160 rw [Equiv.image_eq_preimage_symm]
209161 exact hs.preimage f.symm.monotone
210162
211- theorem IsLowerSet.image (hs : IsLowerSet s) (f : α ≃o β) : IsLowerSet (f '' s : Set β) := by
212- change IsLowerSet ((f : α ≃ β) '' s)
213- rw [Equiv.image_eq_preimage_symm]
214- exact hs.preimage f.symm.monotone
215-
216163theorem OrderEmbedding.image_Ici (e : α ↪o β) (he : IsUpperSet (range e)) (a : α) :
217164 e '' Ici a = Ici (e a) := by
218165 rw [← e.preimage_Ici, image_preimage_eq_inter_range,
@@ -257,32 +204,20 @@ section OrderTop
257204
258205variable [OrderTop α]
259206
207+ @[to_dual]
260208theorem IsLowerSet.top_mem (hs : IsLowerSet s) : ⊤ ∈ s ↔ s = univ :=
261209 ⟨fun h => eq_univ_of_forall fun _ => hs le_top h, fun h => h.symm ▸ mem_univ _⟩
262210
211+ @[to_dual]
263212theorem IsUpperSet.top_mem (hs : IsUpperSet s) : ⊤ ∈ s ↔ s.Nonempty :=
264213 ⟨fun h => ⟨_, h⟩, fun ⟨_a, ha⟩ => hs le_top ha⟩
265214
215+ @[to_dual]
266216theorem IsUpperSet.top_notMem (hs : IsUpperSet s) : ⊤ ∉ s ↔ s = ∅ :=
267217 hs.top_mem.not.trans not_nonempty_iff_eq_empty
268218
269219end OrderTop
270220
271- section OrderBot
272-
273- variable [OrderBot α]
274-
275- theorem IsUpperSet.bot_mem (hs : IsUpperSet s) : ⊥ ∈ s ↔ s = univ :=
276- ⟨fun h => eq_univ_of_forall fun _ => hs bot_le h, fun h => h.symm ▸ mem_univ _⟩
277-
278- theorem IsLowerSet.bot_mem (hs : IsLowerSet s) : ⊥ ∈ s ↔ s.Nonempty :=
279- ⟨fun h => ⟨_, h⟩, fun ⟨_a, ha⟩ => hs bot_le ha⟩
280-
281- theorem IsLowerSet.bot_notMem (hs : IsLowerSet s) : ⊥ ∉ s ↔ s = ∅ :=
282- hs.bot_mem.not.trans not_nonempty_iff_eq_empty
283-
284- end OrderBot
285-
286221section NoMaxOrder
287222
288223variable [NoMaxOrder α]
@@ -323,12 +258,10 @@ section PartialOrder
323258
324259variable [PartialOrder α] {s : Set α}
325260
261+ @[to_dual]
326262theorem isUpperSet_iff_forall_lt : IsUpperSet s ↔ ∀ ⦃a b : α⦄, a < b → a ∈ s → b ∈ s :=
327263 forall_congr' fun a => by simp [le_iff_eq_or_lt, or_imp, forall_and]
328264
329- theorem isLowerSet_iff_forall_lt : IsLowerSet s ↔ ∀ ⦃a b : α⦄, b < a → a ∈ s → b ∈ s :=
330- forall_congr' fun a => by simp [le_iff_eq_or_lt, or_imp, forall_and]
331-
332265theorem isUpperSet_iff_Ioi_subset : IsUpperSet s ↔ ∀ ⦃a⦄, a ∈ s → Ioi a ⊆ s := by
333266 simp [isUpperSet_iff_forall_lt, subset_def, @forall_swap (_ ∈ s)]
334267
@@ -341,6 +274,7 @@ section LinearOrder
341274
342275variable [LinearOrder α] {s t : Set α}
343276
277+ @[to_dual]
344278theorem IsUpperSet.total (hs : IsUpperSet s) (ht : IsUpperSet t) : s ⊆ t ∨ t ⊆ s := by
345279 by_contra! h
346280 simp_rw [Set.not_subset] at h
@@ -349,9 +283,6 @@ theorem IsUpperSet.total (hs : IsUpperSet s) (ht : IsUpperSet t) : s ⊆ t ∨ t
349283 · exact hbs (hs hab has)
350284 · exact hat (ht hba hbt)
351285
352- theorem IsLowerSet.total (hs : IsLowerSet s) (ht : IsLowerSet t) : s ⊆ t ∨ t ⊆ s :=
353- hs.toDual.total ht.toDual
354-
355286theorem IsUpperSet.eq_empty_or_Ici [WellFoundedLT α] (h : IsUpperSet s) :
356287 s = ∅ ∨ (∃ a, s = Set.Ici a) := by
357288 refine or_iff_not_imp_left.2 fun ha ↦ ?_
0 commit comments