Skip to content

Commit 1dc478f

Browse files
committed
chore(Topology/Order/LeftRight): use to_dual (#35637)
This overlaps with #35635, but the overlap is small (and that PR still needs some work, so I'd rather get this out of the way first).
1 parent 90795a0 commit 1dc478f

File tree

3 files changed

+33
-26
lines changed

3 files changed

+33
-26
lines changed

Mathlib/Order/Interval/Set/LinearOrder.lean

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,31 +156,35 @@ theorem Iio_subset_Iic_iff [DenselyOrdered α] : Iio a ⊆ Iic b ↔ a ≤ b :=
156156

157157
/-! ### Two infinite intervals -/
158158

159+
@[to_dual]
159160
theorem Iic_union_Ioi_of_le (h : a ≤ b) : Iic b ∪ Ioi a = univ :=
160161
eq_univ_of_forall fun x => (h.gt_or_le x).symm
161162

163+
@[to_dual]
162164
theorem Iio_union_Ici_of_le (h : a ≤ b) : Iio b ∪ Ici a = univ :=
163165
eq_univ_of_forall fun x => (h.ge_or_lt x).symm
164166

167+
@[to_dual]
165168
theorem Iic_union_Ici_of_le (h : a ≤ b) : Iic b ∪ Ici a = univ :=
166169
eq_univ_of_forall fun x => (h.ge_or_le x).symm
167170

171+
@[to_dual]
168172
theorem Iio_union_Ioi_of_lt (h : a < b) : Iio b ∪ Ioi a = univ :=
169173
eq_univ_of_forall fun x => (h.gt_or_lt x).symm
170174

171-
@[simp]
175+
@[to_dual (attr := simp)]
172176
theorem Iic_union_Ici : Iic a ∪ Ici a = univ :=
173177
Iic_union_Ici_of_le le_rfl
174178

175-
@[simp]
179+
@[to_dual (attr := simp)]
176180
theorem Iio_union_Ici : Iio a ∪ Ici a = univ :=
177181
Iio_union_Ici_of_le le_rfl
178182

179-
@[simp]
183+
@[to_dual (attr := simp)]
180184
theorem Iic_union_Ioi : Iic a ∪ Ioi a = univ :=
181185
Iic_union_Ioi_of_le le_rfl
182186

183-
@[simp]
187+
@[to_dual (attr := simp)]
184188
theorem Iio_union_Ioi : Iio a ∪ Ioi a = {a}ᶜ :=
185189
ext fun _ => lt_or_lt_iff_ne
186190

Mathlib/Tactic/Translate/ToDual.lean

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ def abbreviationDict : Std.HashMap String String := .ofList [
227227
("predColimit", "PredLimit"),
228228
("codirectedOrder", "DirectedOrder"),
229229
("directedOrder", "CodirectedOrder"),
230+
("nhdsLT", "NhdsGT"),
231+
("nhdsGT", "NhdsLT"),
232+
("nhdsLE", "NhdsGE"),
233+
("nhdsGE", "NhdsLE"),
234+
("neTop", "NeBot")
230235
]
231236

232237
/-- The bundle of environment extensions for `to_dual` -/

Mathlib/Topology/Order/LeftRight.lean

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,35 +35,26 @@ section Preorder
3535

3636
variable {α : Type*} [TopologicalSpace α] [Preorder α]
3737

38+
@[to_dual frequently_gt_nhds]
3839
lemma frequently_lt_nhds (a : α) [NeBot (𝓝[<] a)] : ∃ᶠ x in 𝓝 a, x < a :=
3940
frequently_iff_neBot.2 ‹_›
4041

41-
lemma frequently_gt_nhds (a : α) [NeBot (𝓝[>] a)] : ∃ᶠ x in 𝓝 a, a < x :=
42-
frequently_iff_neBot.2 ‹_›
43-
42+
@[to_dual exists_gt]
4443
theorem Filter.Eventually.exists_lt {a : α} [NeBot (𝓝[<] a)] {p : α → Prop}
4544
(h : ∀ᶠ x in 𝓝 a, p x) : ∃ b < a, p b :=
4645
((frequently_lt_nhds a).and_eventually h).exists
4746

48-
theorem Filter.Eventually.exists_gt {a : α} [NeBot (𝓝[>] a)] {p : α → Prop}
49-
(h : ∀ᶠ x in 𝓝 a, p x) : ∃ b > a, p b :=
50-
((frequently_gt_nhds a).and_eventually h).exists
51-
47+
@[to_dual]
5248
theorem nhdsWithin_Ici_neBot {a b : α} (H₂ : a ≤ b) : NeBot (𝓝[Ici a] b) :=
5349
nhdsWithin_neBot_of_mem H₂
5450

55-
instance nhdsGE_neBot (a : α) : NeBot (𝓝[≥] a) := nhdsWithin_Ici_neBot (le_refl a)
56-
57-
theorem nhdsWithin_Iic_neBot {a b : α} (H : a ≤ b) : NeBot (𝓝[Iic b] a) :=
58-
nhdsWithin_neBot_of_mem H
59-
51+
@[to_dual]
6052
instance nhdsLE_neBot (a : α) : NeBot (𝓝[≤] a) := nhdsWithin_Iic_neBot (le_refl a)
6153

54+
@[to_dual]
6255
theorem nhdsLT_le_nhdsNE (a : α) : 𝓝[<] a ≤ 𝓝[≠] a :=
6356
nhdsWithin_mono a fun _ => ne_of_lt
6457

65-
theorem nhdsGT_le_nhdsNE (a : α) : 𝓝[>] a ≤ 𝓝[≠] a := nhdsWithin_mono a fun _ => ne_of_gt
66-
6758
-- TODO: add instances for `NeBot (𝓝[<] x)` on (indexed) product types
6859

6960
lemma IsAntichain.interior_eq_empty [∀ x : α, (𝓝[<] x).NeBot] {s : Set α}
@@ -84,54 +75,57 @@ section PartialOrder
8475

8576
variable {α β : Type*} [TopologicalSpace α] [PartialOrder α] [TopologicalSpace β]
8677

78+
@[to_dual]
8779
theorem continuousWithinAt_Ioi_iff_Ici {a : α} {f : α → β} :
8880
ContinuousWithinAt f (Ioi a) a ↔ ContinuousWithinAt f (Ici a) a := by
8981
simp only [← Ici_diff_left, continuousWithinAt_diff_self]
9082

91-
theorem continuousWithinAt_Iio_iff_Iic {a : α} {f : α → β} :
92-
ContinuousWithinAt f (Iio a) a ↔ ContinuousWithinAt f (Iic a) a :=
93-
continuousWithinAt_Ioi_iff_Ici (α := αᵒᵈ)
94-
83+
@[to_dual]
9584
theorem continuousWithinAt_inter_Ioi_iff_Ici {a : α} {f : α → β} {s : Set α} :
9685
ContinuousWithinAt f (s ∩ Ioi a) a ↔ ContinuousWithinAt f (s ∩ Ici a) a := by
9786
simp [← Ici_diff_left, ← inter_diff_assoc, continuousWithinAt_diff_self]
9887

99-
theorem continuousWithinAt_inter_Iio_iff_Iic {a : α} {f : α → β} {s : Set α} :
100-
ContinuousWithinAt f (s ∩ Iio a) a ↔ ContinuousWithinAt f (s ∩ Iic a) a :=
101-
continuousWithinAt_inter_Ioi_iff_Ici (α := αᵒᵈ)
102-
10388
end PartialOrder
10489

10590
section TopologicalSpace
10691

10792
variable {α β : Type*} [TopologicalSpace α] [LinearOrder α] [TopologicalSpace β] {s : Set α}
10893

94+
@[to_dual nhdsGE_sup_nhdsLE]
10995
theorem nhdsLE_sup_nhdsGE (a : α) : 𝓝[≤] a ⊔ 𝓝[≥] a = 𝓝 a := by
11096
rw [← nhdsWithin_union, Iic_union_Ici, nhdsWithin_univ]
11197

98+
@[to_dual nhdsWithinGE_sup_nhdsWithinLE]
11299
theorem nhdsWithinLE_sup_nhdsWithinGE (a : α) : 𝓝[s ∩ Iic a] a ⊔ 𝓝[s ∩ Ici a] a = 𝓝[s] a := by
113100
rw [← nhdsWithin_union, ← inter_union_distrib_left, Iic_union_Ici, inter_univ]
114101

102+
@[to_dual nhdsGT_sup_nhdsLE]
115103
theorem nhdsLT_sup_nhdsGE (a : α) : 𝓝[<] a ⊔ 𝓝[≥] a = 𝓝 a := by
116104
rw [← nhdsWithin_union, Iio_union_Ici, nhdsWithin_univ]
117105

106+
@[to_dual nhdsWithinGT_sup_nhdsWithinLE]
118107
theorem nhdsWithinLT_sup_nhdsWithinGE (a : α) : 𝓝[s ∩ Iio a] a ⊔ 𝓝[s ∩ Ici a] a = 𝓝[s] a := by
119108
rw [← nhdsWithin_union, ← inter_union_distrib_left, Iio_union_Ici, inter_univ]
120109

110+
@[to_dual nhdsGE_sup_nhdsLT]
121111
theorem nhdsLE_sup_nhdsGT (a : α) : 𝓝[≤] a ⊔ 𝓝[>] a = 𝓝 a := by
122112
rw [← nhdsWithin_union, Iic_union_Ioi, nhdsWithin_univ]
123113

114+
@[to_dual nhdsWithinGE_sup_nhdsWithinLT]
124115
theorem nhdsWithinLE_sup_nhdsWithinGT (a : α) : 𝓝[s ∩ Iic a] a ⊔ 𝓝[s ∩ Ioi a] a = 𝓝[s] a := by
125116
rw [← nhdsWithin_union, ← inter_union_distrib_left, Iic_union_Ioi, inter_univ]
126117

118+
@[to_dual nhdsGT_sup_nhdsLT]
127119
theorem nhdsLT_sup_nhdsGT (a : α) : 𝓝[<] a ⊔ 𝓝[>] a = 𝓝[≠] a := by
128120
rw [← nhdsWithin_union, Iio_union_Ioi]
129121

122+
@[to_dual nhdsWithinGT_sup_nhdsWithinLT]
130123
theorem nhdsWithinLT_sup_nhdsWithinGT (a : α) :
131124
𝓝[s ∩ Iio a] a ⊔ 𝓝[s ∩ Ioi a] a = 𝓝[s \ {a}] a := by
132125
rw [← nhdsWithin_union, ← inter_union_distrib_left, Iio_union_Ioi, compl_eq_univ_diff,
133126
inter_sdiff_left_comm, univ_inter]
134127

128+
@[to_dual nhdsLT_sup_nhdsWithin_singleton]
135129
lemma nhdsGT_sup_nhdsWithin_singleton (a : α) :
136130
𝓝[>] a ⊔ 𝓝[{a}] a = 𝓝[≥] a := by
137131
simp only [union_singleton, Ioi_insert, ← nhdsWithin_union]
@@ -142,20 +136,24 @@ lemma nhdsWithin_uIoo_left_le_nhdsNE {a b : α} : 𝓝[uIoo a b] a ≤ 𝓝[≠]
142136
lemma nhdsWithin_uIoo_right_le_nhdsNE {a b : α} : 𝓝[uIoo a b] b ≤ 𝓝[≠] b :=
143137
nhdsWithin_mono _ (by simp)
144138

139+
@[to_dual none]
145140
theorem continuousAt_iff_continuous_left_right {a : α} {f : α → β} :
146141
ContinuousAt f a ↔ ContinuousWithinAt f (Iic a) a ∧ ContinuousWithinAt f (Ici a) a := by
147142
simp only [ContinuousWithinAt, ContinuousAt, ← tendsto_sup, nhdsLE_sup_nhdsGE]
148143

144+
@[to_dual none]
149145
theorem continuousAt_iff_continuous_left'_right' {a : α} {f : α → β} :
150146
ContinuousAt f a ↔ ContinuousWithinAt f (Iio a) a ∧ ContinuousWithinAt f (Ioi a) a := by
151147
rw [continuousWithinAt_Ioi_iff_Ici, continuousWithinAt_Iio_iff_Iic,
152148
continuousAt_iff_continuous_left_right]
153149

150+
@[to_dual none]
154151
theorem continuousWithinAt_iff_continuous_left_right {a : α} {f : α → β} :
155152
ContinuousWithinAt f s a ↔
156153
ContinuousWithinAt f (s ∩ Iic a) a ∧ ContinuousWithinAt f (s ∩ Ici a) a := by
157154
simp only [ContinuousWithinAt, ← tendsto_sup, nhdsWithinLE_sup_nhdsWithinGE]
158155

156+
@[to_dual none]
159157
theorem continuousWithinAt_iff_continuous_left'_right' {a : α} {f : α → β} :
160158
ContinuousWithinAt f s a ↔
161159
ContinuousWithinAt f (s ∩ Iio a) a ∧ ContinuousWithinAt f (s ∩ Ioi a) a := by

0 commit comments

Comments
 (0)